-
Notifications
You must be signed in to change notification settings - Fork 12.2k
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
Google gtag.js is now recommended over analytics.js #2014
Comments
Report back on what you find. (in addition to updating the docs ) I'm so many years removed from working on sites (vs. super-secret doubleplus fancy web apps) that I don't have any clue about this stuff anymore. |
Where did we land with this? |
Actually, gtag.js installation: IP anonymization w/ gtag.js: Example:
|
Hi @Malvoz - yes, I'm sure many of the tracking snippet scripts we have for analytics.js (Anonymize IP addresses, Track jQuery AJAX requests, Track JavaScript errors and Track page scroll) are also available to use in some form or another for gtag.js, but the implementation is different... so with gtag it'd be: The scripts for tracking outbound links are different too and the 'track javascript errors' script we have (https://github.com/h5bp/html5-boilerplate/blob/master/src/doc/extend.md#track-javascript-errors-in-google-analytics) doesn't work with gtag.js so would need to be rewritten. Overall, I found that if the only Google script/service you need on your site is Google Analytics then it's simpler to use So for H5BP we either need to update our tracking scripts to work with |
I find this comment by Philip Walton a convincing argument not to switch to
|
I recently did a bit of a deep dive to understand some of the differences between analytics.js and gtag.js - one small thing that is worth considering is that gtag does not support the Plugin format that analytics.js supports, so moving to this may break some future implementation plans, but probably fine for the boilerplate. |
Finally got round to addressing this with a PR. (#2118) - Thanks for the feedback @jcutrell and @TheDancingCode ! |
The following extensions could be useful |
I used ga for several years, today I found that google analytics code recommend changed from ga to gtag. I am very confused why google update ga to gtag,what is the benefit ? |
@fbens, it is adding all google trackings using one tracking including GA, AdWords, Remarketing, Optimizer etc. It is used for multiple trackings instead of just GA. Hope it helps |
When adding a new site to Google Analytics the tracking code provided is now gtag.js which works a bit differently to the previously recommended analytics.js.
Google Universal Analytics (Analytics.js) is still available to users but I think we need to clarify in the documentation that the useful tracking snippets we currently have in H5BP (Anonymize IP addresses, Track jQuery AJAX requests, Track JavaScript errors and Track page scroll) are for analytics.js and not gtag.js.
Today I'm working on migrating a site from analytics.js to gtag.js (following this guide: https://developers.google.com/analytics/devguides/collection/gtagjs/migration) so will see if the snippets we have can be updated to work with gtag.js.
If anyone has any additional thoughts on this, please chime in.
The text was updated successfully, but these errors were encountered: