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 single page notification button data attributes for tracking #2471
Conversation
ca7216f
to
f546f9b
Compare
f546f9b
to
8a648c1
Compare
8a648c1
to
f209d3e
Compare
Re-drafted this while I investigate another potential tracking issue which could go in the same PR |
f209d3e
to
1ce4bab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing wrong here but I'm wondering about the approach, although I could be wrong.
...assets/javascripts/govuk_publishing_components/components/single-page-notification-button.js
Outdated
Show resolved
Hide resolved
...assets/javascripts/govuk_publishing_components/components/single-page-notification-button.js
Outdated
Show resolved
Hide resolved
5b7dece
to
18a344e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks good. I think originally there was a test for the JavaScript behaviour, but that seems to have disappeared? Would be worth putting it back in.
The data attributes for tracking are not named correctly. data-label should be data-track-label, data-action should be data-track-action, data-category should be data-track-category.
Apply the data-module="gem-track-click" for the single page notification button to a component wrapper div. The reason behind applying this to a wrapper and not to the form is that the form gets swapped out with the form returned from the personalisation endpoint, so the track click module would have to be re-started on the new, updated form. Applying the track-click attribute to a wrapper instead means we don't have to re-start the gem-track-click module for the updated form.
414c76c
to
2dc71b5
Compare
The
data-label
attribute should bedata-track-label
,data-action
should bedata-track-action
,data-category
should bedata-track-category
.data-module=gem-track-click
attribute to a wrapper div instead of the form itself. The reason for this is thatthe form gets dynamically swapped out with the form returned from the personalisation endpoint. If
data-module=gem-track-click
was applied to the form, then in order for click tracking to fire correctly after the JS update has occurred, the track click module would have to be re-started on the updated form, which is not ideal.This is a workaround which can be credited to @andysellick