Closed spaceribs closed 6 years ago
Thanks for the suggestion! As it turns out, all gtag.js does is load analytics.js and pass it commands. It's mean to act as a layer of syntactical sugar to support multiple Google tools, so we're actually kind of cracking the same nut here, as far as I can see.
Interesting! so basically the "ga" global is loaded in the page as well as "gtag"? are there any disadvantages to calling "ga" directly?
Yup, you got it; when gtag loads, it processes the config commands, then fetches whatever libraries it requires (in this case analytics.js) and sets up the command queue for that tool. You can see it all go down in the gtag.js source.
Gtag sets up a named tracker (similar to GTM), so trying to mix gtag and analytics.js will probably not go super great.
Semi-recently, gtag.js was released. It would be great if this library supported the new standard: https://developers.google.com/analytics/devguides/collection/gtagjs/migration