Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GA4 tracking to some missions page blocks #4534

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

AshGDS
Copy link
Contributor

@AshGDS AshGDS commented Dec 16, 2024

What / Why

  • Adds GA4 tracking to some missions page blocks as this was missing in the initial release
  • Adds the link tracker for the Menu, Boxes and Org logo links
  • Adds the event tracker for the Menu button
  • See the implementation guide if you'd like to verify the JSON values.
  • I had to create a new container block for the boxes to give me a nice way to track them. This is because they're rendered separately from each other in the code, and for the purposes of GA4 indexes I needed to capture all of them in one <div> so the indexes could be set. Therefore there's a new box_container block. (I didn't want to add the tracking on to the existing columns_layout <div> that surrounds all of them already, as I don't think columns_layout should have any tracking on it.)
  • Trello cards:

@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4534 December 16, 2024 13:05 Inactive
@AshGDS AshGDS force-pushed the ga4-missions-pages branch from 2e1fc41 to 98fe48a Compare December 16, 2024 13:13
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4534 December 16, 2024 13:14 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4534 December 16, 2024 15:16 Inactive
@AshGDS AshGDS changed the title Missions pages GA4 tracking Add GA4 tracking to missions pages Dec 16, 2024
@AshGDS AshGDS changed the title Add GA4 tracking to missions pages Add GA4 tracking to some missions page blocks Dec 16, 2024
@AshGDS AshGDS marked this pull request as ready for review December 16, 2024 15:28
@AshGDS AshGDS requested a review from andysellick December 16, 2024 15:32
Copy link
Contributor

@andysellick andysellick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question about the approach and a couple of small things.

app/views/landing_page/blocks/_box_container.html.erb Outdated Show resolved Hide resolved
app/views/landing_page/blocks/_main_navigation.html.erb Outdated Show resolved Hide resolved
app/views/landing_page/blocks/_main_navigation.html.erb Outdated Show resolved Hide resolved
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4534 December 16, 2024 16:23 Inactive
@AshGDS AshGDS force-pushed the ga4-missions-pages branch from 4affa9c to 658160e Compare December 16, 2024 16:23
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4534 December 16, 2024 16:23 Inactive
We need to set indexes on each box even though they are defined separately in the code. We also need to preserve the columns layout, so creating a container around all the boxes and taking advatnage of the JS index setting function in our GA4 code seemed most logical
@AshGDS AshGDS force-pushed the ga4-missions-pages branch from 658160e to 0b7ed1d Compare December 16, 2024 16:34
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4534 December 16, 2024 16:35 Inactive
Fix select content typo
Use each_with_index
@AshGDS AshGDS force-pushed the ga4-missions-pages branch from 0b7ed1d to ba1308b Compare December 16, 2024 16:35
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4534 December 16, 2024 16:36 Inactive
@AshGDS
Copy link
Contributor Author

AshGDS commented Dec 16, 2024

Thanks @andysellick - should be ready to re-review. Also had to rebase as the organisation logo's render statement moved to a new template.

@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4534 December 17, 2024 12:35 Inactive
@AshGDS AshGDS force-pushed the ga4-missions-pages branch from d935ae7 to 4d52de5 Compare December 17, 2024 12:40
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4534 December 17, 2024 12:40 Inactive
@AshGDS
Copy link
Contributor Author

AshGDS commented Dec 17, 2024

Thanks @andysellick - should be ready to review again 👍

Copy link
Contributor

@andysellick andysellick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, and cleaner too. Just a couple of minor comments - also are there any tests that should be included here? Maybe one to check that if the ga4_tracking is applied to a block that the expected attributes appear?

ga4_track_links_only: "",
ga4_link: {
event_name: "navigation",
seciton: "Header",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: seciton

@@ -382,6 +382,7 @@ Note that the `[Image: desktop.png]` syntax must be wrapped in quotes (`"[Image:
Layout blocks are similar to compound blocks in that they contain nested blocks. They are used to arrange blocks on the page, and to make it easier to apply styling to the blocks.

- [Blocks Container](#blocks-container)
- [Box Container](#box-container)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably this documentation can be removed now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants