-
Notifications
You must be signed in to change notification settings - Fork 20
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 for search autocomplete #4371
Conversation
199bbb1
to
ba46736
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.
Looks good to me. Only thing I'm a bit confused by is using different methods to set/get data attributes - it's unclear to me if that's on purpose or not.
app/assets/javascripts/govuk_publishing_components/components/search-with-autocomplete.js
Outdated
Show resolved
Hide resolved
'my favourite album is folklore', | ||
'my favourite album is reputation', | ||
'my favourite album is 1989' | ||
]) |
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.
Had not realised you were a swiftie 😁
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.
Oh you'll enjoy the Finder Frontend search tests 😂 I've almost crowded out @sihugh's Harry Potter references!
ba46736
to
c5c7583
Compare
This adds a set of tracking attributes to the `search_with_autocomplete` component, which will be able to be picked up by the GA4 search tracker to measure user interaction with the autocomplete component. In particular, this adds: - `autocomplete-trigger-input`: the original, possibly partial, input from the user that triggered the offered suggestions - `autocomplete-accepted`: whether the user has accepted a suggestion (as opposed to dismissed the autocomplete with Escape or clicking outside) - `autocomplete-suggestions`: a string containing a pipe-separated list of the (up to) five top suggestions offered - `autocomplete-suggestions-count`: the total number of suggestions offered
This uses the new analytics data attributes that we set in the `search_with_autocomplete` component to enhance the `search` event we send to GA4 with autocomplete usage data.
These have been agreed on for the autocomplete tracking.
c5c7583
to
03834fe
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.
Looks good 👍
What
This PR:
search_with_autocomplete
componentGa4SearchTracker
to pick them up as part of thesearch
eventsearch
event fieldsWhy
We will soon be going live with autocomplete for site search on GOV.UK and need to track user interactions to see if it works as intended.
See measurement approach document (internal) for details on why we're measuring what we're measuring, and the approach taken.