Implement grid view analytics#514
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
49fc5a8 to
4780398
Compare
|
mmm I'm not seeing the data in |
nvm I was looking at the wrong location |
|
Reviewed this with @isastettler because she's also working on GA4 event tracking in the Scout app.
Looks like this was already made and it makes sense.
This may not be the most ideal way to track object updates, but it works well and is a common pattern. It's doing string comparison over the shallow object diff. I'm surprised that We verified the data is set in |
Send an event when a user explicitly clicks on the list or grid view button selection.
Add a getter to the search manager that collates analytics data on searches, then pass that search data to ga4 in a useEffect in the various search interfaces.
We are eventually going to pass title cased params to ga4, but since the code is generally using lowercase, let's pass in lowercase
Move this into the ga4 utils and make search type possibly undefined to clarify the contract.
Define a hook to extract the search analytics code, and remove the Analytics stuff from the SearchManager to keep it cleaner
if the viewmode is the only thing that changed, we don't want to send this event.
JS / TS arrays are truthy even when empty - so check the array length. As the code was written, we were sending up "" when there were no filters selected.
a9c24a0 to
1906215
Compare
7emansell
left a comment
There was a problem hiding this comment.
Agree that the useSearchAnalytics makes more sense as a hook and shouldn't be on the searchManager, and seeing expected event data in the console 👍
Ticket:
This PR does the following:
Note, this is branched off #497, I'll wait for that to go in before publishing this PR.
Adds two events for grid view to ga4:
Open questions
For the search analytics, I implemented this by standardizing the search analytics data in the search manager object, and then using that data as dependencies for an effect (so that if the search params change, a new event is sent).
useEffectcalls be refactored into their own hook?filterNameswould still suffer the same issue.How has this been tested? How should a reviewer test this?
Tested on vercel by inspecting
window.dataLayerin the console.I'll add a couple unit tests as well.
Accessibility concerns or updates
Checklist: