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

Allow custom text for GA4 scroll tracker #3896

Merged
merged 1 commit into from Mar 4, 2024
Merged

Conversation

andysellick
Copy link
Contributor

What

Rework the GA4 scroll tracker slightly so that when tracking headings or markers, the text collected in the event can be set to something else using a data attribute, instead of automatically collecting the text of the element.

Example:

<h1>
  This text will be recorded
</h1>
<h2 data-ga4-text="this text will be recorded in the event">
  This text will be ignored
</h2>

Why

Allows us to record the headings consistently in the GA4 data using one language. Currently getting a lot of data for when pages are translated in different languages, which analysis harder.

Visual Changes

None.

Trello card: https://trello.com/c/VzWOeSJt/798-placeholder-scroll-tracking-heading-marker-question-translations

Copy link
Contributor

@AshGDS AshGDS 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 👍 , though I think you're missing a test that checks data-ga4-text works?

@andysellick
Copy link
Contributor Author

@AshGDS 🤦

After all that effort of changing around the tests and redoing all the logic, you're right, I completely failed to actually test the thing I meant to test. Have rewritten - and made a bit simpler too.

Copy link
Contributor

@AshGDS AshGDS left a comment

Choose a reason for hiding this comment

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

LGTM 👍

- allows text of headings and markers to be overridden using a custom `data-ga4-text` attribute
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-3896 March 4, 2024 12:42 Inactive
@andysellick andysellick merged commit 6767a8d into main Mar 4, 2024
12 checks passed
@andysellick andysellick deleted the scroll-tracker-text branch March 4, 2024 12:44
@andysellick andysellick mentioned this pull request Mar 8, 2024
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.

None yet

3 participants