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

Fix toggle click tracking on step-by-steps #1925

Merged
merged 2 commits into from
Feb 12, 2021
Merged

Conversation

alex-ju
Copy link
Contributor

@alex-ju alex-ju commented Feb 12, 2021

What

In #1893 we added an SVG to the step by step navigation continuing to rely on the same logic for tracking, but the way the toggle click tracking script is designed expects the element triggering the click event to be an HTMLElement, not a path element, which causes a hard error and fails to send data to GA. With this change, we avoid capturing events at the SVG level, which means they will bubble and be captured by the parent HTMLElement.

Why

  • step-by-step-nav script fails on pages when users click the SVG element
  • we are losing tracking data since 9 Feb

Visual Changes

No visual changes

Example page: https://www.gov.uk/apply-transit-visa

BeforeAfter
before-track after-track
before-js

No JavaScript errors

In #1893 we added an SVG to the step by step navigation continuing to rely on the same logic for tracking, but the way the toggle click tracking script is designed expects the element triggering the click event to be an HTMLElement, not a path element, which causes a hard error and fails to send data to GA. With this change, we avoid capturing events at the SVG level, which means they will bubble and be captured by the parent HTMLElement.
@bevanloon bevanloon temporarily deployed to govuk-publis-fix-step-b-5a45hu February 12, 2021 15:39 Inactive
@bevanloon bevanloon temporarily deployed to govuk-publis-fix-step-b-5a45hu February 12, 2021 15:41 Inactive
Copy link
Contributor

@owenatgov owenatgov left a comment

Choose a reason for hiding this comment

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

Great spot, great solution, great!

@alex-ju alex-ju merged commit 5e75087 into master Feb 12, 2021
@alex-ju alex-ju deleted the fix-step-by-step-tracking branch February 12, 2021 15:47
alex-ju added a commit that referenced this pull request Feb 15, 2021
## 24.1.1

* Fix deprecation warnings when running tests ([PR #1899](#1899))
* Update `govuk-frontend` base SCSS imports ([PR #1922](#1922))
* Remove redundant import in accordion component ([PR #1923](#1923))
* Fix toggle click tracking on step-by-steps ([PR #1925](#1925))
* Accordion summary design adjustment ([PR #1926](#1926))
* Fix `layout_header` layout and spacing issues ([PR #1924](#1924))
@alex-ju alex-ju mentioned this pull request Feb 15, 2021
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