ga4 tracking for filter/sorting UI interaction
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-expandableattribute 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-expandableattribute 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.jsscript. The newall-content-findersearch 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-summarycomponent) usega4-event-trackerattribute and standard child attributes to track when they are clicked.
No visual changes.
@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
@alexbowen it's possible that some existing functionality using the
data-ga4-expandableattribute 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.