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

  • Resolved Metuza

    (@metuza)


    Hello,

    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.

    Brgds
    Rune

    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

    (@daanvandenbergh)

    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.

    Roger

    (@rogerwheatley)

    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

    (@daanvandenbergh)

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

    CK MacLeod

    (@ck-macleod)

    @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

    (@daanvandenbergh)

    @metuza, @ck-macleod, @rogerwheatley,

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

    Enjoy!

    CK MacLeod

    (@ck-macleod)

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

    CK MacLeod

    (@ck-macleod)

    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: https://gtmetrix.com/reports/staging-calldixie.duffymarketing.com/zRM0bLpN

    Loading only once: https://gtmetrix.com/reports/staging-calldixie.duffymarketing.com/GIbLuflU

    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 2 months ago by  CK MacLeod.
    Plugin Author Daan van den Bergh

    (@daanvandenbergh)

    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.

    CK MacLeod

    (@ck-macleod)

    The analytics js that’s loaded in both versions is http://y7w3z2r4.stackpathcdn.com/wp-content/cache/caos-analytics/analytics.js, so appears to be the caos version by way of the CDN setting.

    I don’t know why the call to Google – https://www.google-analytics.com/analytics.js – 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

    (@daanvandenbergh)

    I understand. All I can tell you is: CAOS for Analytics doesn’t insert anything anywhere with an external source in it, such as google-analytics.com or googletagmanager.com. 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

    (@daanvandenbergh)

    @ck-macleod,

    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. 🙂

    @daanvandenbergh

    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)
  • You must be logged in to reply to this topic.