Support » Plugin: CAOS | Host Google Analytics Locally » Use of gtag.js as recommended by google

  • Resolved ArcticFritid



    Any plans on follow up on google recommendations and migrate analytics.js to gtag.js?

    I am now using only gtag.js for all analytics, adwords conversions and remarketing ads and it works very well.


    The page I need help with: [log in to see the link]

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Daan van den Bergh


    I’d have to test it. Google doesn’t allow locally hosting gtm.js, but I hadn’t heard of gtag.js, so I’d have to test it.

    Same issue here. Google uses gtag.js (it’s been in use for a while now). I randomly checked a few websites (about 5 or 6, some number like that) of people I know, and all the ones I looked at were using gtag.js
    Any possible update or news on this? Thanks, appreciated!

    Plugin Author Daan van den Bergh


    I’m working on a new release which supports gtag.js instead of analytics.js.

    @daanvandenbergh Looking forward to it – I plan to be an early adopter for multiple sites I’m running – assuming it works! 😉

    Plugin Author Daan van den Bergh


    @metuza, @ck-macleod, @rogerwheatley,

    You are going to be happy campers today! I just added gtag.js support in the latest version!


    Great… I’ll let you know how it goes, and I hope I’ll be able to 5-star your plugin.

    So far I’m getting uneven results: On repeated tests, sometimes analytics.js loads from my CDN at my test site only, and sometimes it loads twice.

    Loading twice:

    Loading only once:

    I thought maybe it was loading a second time with the noscript/footer tag (which I don’t consider essential at all for our sites), but the load-twice version happens even with the footer tag removed.

    • This reply was modified 1 year, 6 months ago by CK MacLeod.
    Plugin Author Daan van den Bergh


    Ok, so, the first example (loading twice) isn’t caused by CAOS. You need to disable whatever plugin or other tag that is adding the external analytics.js.

    The second one is still loading gtag from the external URL. Also causef by another plugin (or maybe a manually added into your code?) You can disable that as well if you’re going to use gtag.js in CAOS.

    The analytics js that’s loaded in both versions is, so appears to be the caos version by way of the CDN setting.

    I don’t know why the call to Google – – is going through, o GTMetrix detects it on some tests, but not on others, based on the identical set of plugins with identical coding.

    If I turn off your plugin entirely, then I get a variation on the same issue. On an initial couple of tests, analytics.js isn’t loaded at all. On subsequent tests, it’s loaded.

    I don’t know enough about Google Tag Manager to understand this behavior – what’s actually supposed to be happening, but I should also have some info tomorrow to verify whether the set-up is correct.

    Plugin Author Daan van den Bergh


    I understand. All I can tell you is: CAOS for Analytics doesn’t insert anything anywhere with an external source in it, such as or Perhaps your CDN isn’t entirely flushed? That might explain why sometimes these sources are loaded, and sometimes they’re not.

    Plugin Author Daan van den Bergh



    Just thought to get back to you, since I finally found an answer to your question:

    gtag.js is a wrapper library for analytic.js, that’s why the external request to analytics.js was still done, when using gtag.js. Buuut, in a recent update I managed to fix that. So no both gtag.js AND analytics.js are loaded locally, when using gtag.js in CAOS. 🙂


    Cool! I’m not going to pretend that I understand the behavior completely, but I’ll be giving the new version a try the next time I tackle GA/Gtags at a site I manage.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Use of gtag.js as recommended by google’ is closed to new replies.