Track select
interactions in Whitehall
#10069
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Send data to GA4 in response to
change
events that occur on those<select>
elements which are not part of aselect_with_search
component. Further information is provided in the Trello card<select>
elements within the codebase (See 000a6c1)<select>
elements coming from the components Gem withdata_attributes
govuk_publishing_components/components/select
in WhitehallHow
Introduces a new analytics
GA4SelectSetup
module that sends data to GA4 in response tochange
events on only those select elements that are not part of aselect_with_search
component (See #9983 for details of how theselect_with_search
components are tracked using custom events provided by choices.js).The
select_with_search
components have been excluded through the selector used to build the nodeList:"select:not([data-module~='select-with-search'] select)"
This queries for all select elements that do not have an ancestor with the
select-with-search
data-module. This approach is necessary to avoid multiple submissions in response to a single change inselect_with_search
.Following the implementation of other analytics modules, a new module is added to the HTML (
ga4-select-setup
) to allow for control of when this tracking is enabled.Performance analyst review
[To be done]
Related PRs
select_with_search
#9983 Introduced GA4 tracking toselect_with_search
components