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

Add GA4 tracking for search autocomplete #4371

Merged
merged 3 commits into from
Nov 6, 2024
Merged

Add GA4 tracking for search autocomplete #4371

merged 3 commits into from
Nov 6, 2024

Conversation

csutter
Copy link
Contributor

@csutter csutter commented Nov 6, 2024

What

This PR:

  • adds tracking attributes to the search_with_autocomplete component
  • amends the Ga4SearchTracker to pick them up as part of the search event
  • extends the GA4 schema to cover the new search event fields

Why

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.

Copy link
Member

@kevindew kevindew 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 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.

'my favourite album is folklore',
'my favourite album is reputation',
'my favourite album is 1989'
])
Copy link
Member

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 😁

Copy link
Contributor Author

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!

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.
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4371 November 6, 2024 16:16 Inactive
Copy link
Member

@kevindew kevindew 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 👍

@csutter csutter merged commit 5a92892 into main Nov 6, 2024
12 checks passed
@csutter csutter deleted the autocomp-track branch November 6, 2024 17:33
csutter added a commit that referenced this pull request Nov 7, 2024
* Add GA4 tracking for search autocomplete ([PR #4371](#4371))
* Append no-actions class to rows without actions in Summary Cards ([PR #4368](#4368))
* Search with autocomplete: Work around Enter edge case ([PR #4372](#4372))
@csutter csutter mentioned this pull request Nov 7, 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.

3 participants