-
Notifications
You must be signed in to change notification settings - Fork 283
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
Add support for Google Analytics 4 #160
Comments
GA4 requires much more client side JS AFAIK, so I'm not planning to add support. Legacy GA works just fine. If you'd send a PR, I'd be happy to take a look. |
Just to say I would also be interested in understanding how to do this, even if it doesn't necessarily get merged - let me know if I can assist at all. |
Hi @JamesLMilner, here is what I did in my personal blog generated from the template. I see results in the ga4 dashboard so this "works" but may not be optimal given it was a self-reviewed PR over the holiday 😅. If you spot anything that could be improved, please let me know and I'll open a PR to the template. Added a copy of gtag.js to
I also updated
and replaced the
|
You can of course totally do this! It just won't have the 100% first-party support that was there for legacy GA |
Tomorrow UA is officially sunset. |
Support for GA4 should be added to prevent a lapse in data collection. Universal Analytics (UA) properties will stop processing data on July 1, 2023.
cached.js
contains a copy of analytics.js. I propose we add a new file,gtag.js
with the contents of https://www.googletagmanager.com/gtag/js?id=my-g-id. We would need to retrieve the user's ID from a new field inmetadata.json
. The rationale for a second file is to separate legacy analytics.js and selectively load gtag.js if the user has a GA4 ID.Other areas to update:
webvitals.js
in favor of https://web.dev/vitals-ga4/The text was updated successfully, but these errors were encountered: