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
feat(analytics): allow query/hash changes to be sent to GA #7545
Conversation
window.gtag('config', trackingID, { | ||
page_path: location.pathname, | ||
page_title: document.title, | ||
}); |
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.
Mmm, why?
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.
The config is done here so doing it again here is redundant.
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.
I don't really know the practice here, because here we are also sending page_path
etc. Do we have docs?
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.
Here's the reference I used to verify. I also poked around in some internal code in our org and verified that config does not need to be ran each time. Also, near as I can tell, the page_path
and page_title
are ignored if passed in as a config object. config
is mostly intended for handling multiple property tracker IDs, campaign IDs, etc. Its not intended as a way to log page events.
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.
I see—sounds good to me, then!
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.
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
⚡️ Lighthouse report for the deploy preview of this PR
|
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 👍
That looks like a good default
Not 100% sure all users will like to track hash changes, but we can eventually add an option if someone complains later
window.gtag('config', trackingID, { | ||
page_path: location.pathname, | ||
page_title: document.title, | ||
}); |
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.
Pre-flight checklist
Motivation
This change will allow page transitions (i.e. changes to the query string and bookmark hash) to be sent to Google Analytics
Test Plan
Ran
yarn serve:website
and verified that GA events are being sentRelated issues/PRs