-
Notifications
You must be signed in to change notification settings - Fork 6
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
ga4 tracking for filter/sorting UI interaction #3485
Conversation
@alexbowen it's possible that some existing functionality using the |
66b5903
to
c51f41a
Compare
c51f41a
to
76e83f6
Compare
@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 |
d8ac191
to
7ce7d76
Compare
c27521c
to
2e7f2a7
Compare
2e7f2a7
to
2e706f0
Compare
267301b
to
8457c55
Compare
18e61f6
to
061c4f7
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.
Note to self (@csutter): Not necessarily one for right now, but perhaps with the above code dealing with the new all content finder too, maybe it's worth creating a GOVUK.AllContentFinder
module to not litter the application.js too much.
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.
Yes i was thinking to put this in a more isolated place than here but was in 2 minds about a few places where exactly. so I have left as is for the purposes of this PR, but agreed its a bit lazy just whacking it here in the long run
section: button_text, | ||
text: button_text, | ||
index_section: 0, | ||
index_section_count: 4 |
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.
This probably shouldn't be hardcoded, but rather passed into this component (as the number of sections might change).
section: "Filter and sort", | ||
action: "search", | ||
index_section: 0, | ||
index_section_count: 4, |
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.
Ditto as above, should be a parameter to this component.
event_name: "select_content", | ||
type: "finder", | ||
text: button_text, | ||
section: "Filter and sort", |
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.
This should also be button_text
"data-ga4-event" => { | ||
event_name: "select_content", | ||
type: "finder", | ||
text: "Clear all", |
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.
This should be the same as the text of this link - maybe that should be configurable too?
event_name: "select_content", | ||
type: "finder", | ||
text: "Clear all", | ||
section: "Filter and sort", |
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.
This should be button_text
as well
event_name: "select_content", | ||
type: "finder", | ||
text: clear_all_text, | ||
section: "Selected filters and sorting", |
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.
Should this be heading_text
?
type: "finder", | ||
section: heading_text, | ||
text: heading_text, | ||
index_section: index_section + 1, |
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.
We're already adding 1 to this in the views/finders/all_content_finder_facets/_*_facet.html.erb
partials, should we be doing this again here?
} do %> | ||
<div class="js-all-content-finder-taxonomy-select" data-ga4-change-category="update-filter select" data-ga4-section="Topic"> |
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.
We need to keep the js-all-content-finder-taxonomy-select
on this or it breaks the subtopic updating JS
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.
As the filter_section
component uses the standard component helper we should just be able to put that in classes
on the component itself though.
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.
there was a reason i did this at some point and i did indeed mean to put that class the the container but must have got distracted! so the class is on the component now as that div seems uneccessary
index_section_count: 0, | ||
} | ||
|
||
render_component(heading_text:, data: button_event_attributes.to_json) |
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.
Not sure I follow where data
ends up here?
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.
similar i think a hangover from something early in implementing this, it is included all over tests and have removed all as yes they do absolutely nothing
061c4f7
to
030e35e
Compare
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
data-ga4-expandable
attribute which adds opened/closed to the action property of the event data.data-ga4-expandable
attribute which adds opened/closed to the action property of the event data.finder-frontend/app/assets/javascripts/analytics-ga4/ga4-finder-tracker.js
script. The newall-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-summary
component) usega4-event-tracker
attribute and standard child attributes to track when they are clicked.No visual changes.