finder-frontend icon indicating copy to clipboard operation
finder-frontend copied to clipboard

ga4 tracking for filter/sorting UI interaction

Open alexbowen opened this issue 1 year ago • 2 comments

For new search page implementation, this PR adds ga4 initialisation and attributes to filters and sorting UI to meet requirements listed here:

https://docs.google.com/spreadsheets/d/1dRoxYPatZiNJGYZEc6E_FZ5xeD_aWQdGxQfYK1dUFq0

  • Filter panel is a simple custom accordion and tracking of opening and closing is implemented using the data-ga4-expandable attribute which adds opened/closed to the action property of the event data.
  • Filter sections are standard HTML details elements and tracking of opening and closing is implemented again using the data-ga4-expandable attribute which adds opened/closed to the action property of the event data.
  • Interaction with form elements that apply filtering/sorting adds ga4 events using the existing finder-frontend/app/assets/javascripts/analytics-ga4/ga4-finder-tracker.js script. The new all-content-finder search page uses a form with id to identify it and initialise the tracking scripts if the form is present (and cookie consent has been granted from the user).
  • Filter/sorting remove links and clear all links (filter-summary component) use ga4-event-tracker attribute and standard child attributes to track when they are clicked.

No visual changes.

alexbowen avatar Sep 30 '24 12:09 alexbowen

@alexbowen it's possible that some existing functionality using the data-ga4-expandable attribute might help you here, see: https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics-ga4/trackers/ga4-event-tracker.md#advanced-use

andysellick avatar Sep 30 '24 12:09 andysellick

@alexbowen it's possible that some existing functionality using the data-ga4-expandable attribute might help you here, see: https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics-ga4/trackers/ga4-event-tracker.md#advanced-use

@andysellick Yeah i was aware of this. Will have a look again at this now i am more familiar with ga4 stuff. was having trouble getting data-ga4-expandable to work before but am about to revisit.

alexbowen avatar Oct 02 '24 10:10 alexbowen