-
Notifications
You must be signed in to change notification settings - Fork 202
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
Track Lunr search queries and search-result clicks #1519
Track Lunr search queries and search-result clicks #1519
Conversation
Signed-off-by: Patrice Chalin <[email protected]>
✅ Deploy Preview for vitess ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Signed-off-by: Patrice Chalin <[email protected]>
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.
LGTM!
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.
Thank you for doing this. Hope to see better analytics now and see how the search is performing for the users.
event_category: lunrSearchEventCategory, | ||
event_label: 'Search-result Click', | ||
search_term: searchTerm, | ||
value: searchResultURL, |
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.
from the documentation value
can be a number only, so it cannot be set to string
https://developers.google.com/tag-platform/devguides/events#gtag.js_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.
For a preliminary analysis, see:
search
event to GA4 with the search term as an attribute, at no more than the debounce rate.click
event handler to each search-result item. When a user clicks on a search result, aclick
event is sent to GA4 with the destination link and associated search term as attributes.A note about the deploy preview: the site preview will allow you to confirm that search is still functional, but it won't generate GA4 events, since analytics is only enabled in production. When
_debug
is enabled (which it was for my original commit, but has since been disabled), you can at least see that the tracking functions get called, like this:I've locally built a "production" version of the site, and can confirm that GA4 is receiving both
search
andclick
(related to search) events. Notice thesearch_term
attribute in both events:search
event with event count of 1:click
-event screenshot/cc @harshit-gangal @thisisobate @nate-double-u