• Resolved Rajeev Rajan

    (@rajeevrf)


    I am using CAOS plugin to locally load the Google Analytics/GTM for performance improvements. However when testing the page in Google page Speed Insights, under “Reduce Unused Javascript” and “Reduce Javascript execution time“, both the locally loaded JS file from the CAOS folder and also external files(listed below) from Google Tag Manager & Google Analytics is loading/showing.

    https://www.googletagmanager.com/gtag/js?id=G-########
    https://www.google-analytics.com/analytics.js

    Is this the expected behavior? We are using this CAOS plugin to locally load the GTM file right? Then why these JS files are also being loaded along with locally hosted files?

    TIA

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

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author DaanvandenBergh

    (@daanvandenbergh)

    Hi!

    In that case you should remove the other tracking codes inserting the external JS libraries. That’ll take care of it!

    Thread Starter Rajeev Rajan

    (@rajeevrf)

    Only place where GTM is integrated in the website is via CAOS plugin.

    Are you saying these 2 external JS shouldn’t be displaying in Google Page Speed report? When we are using this plugin, only the js file inside the CAOS folder should load?

    Plugin Author DaanvandenBergh

    (@daanvandenbergh)

    Exactly. CAOS doesn’t load external libraries. So these two libraries are coming from somewhere else!

    Thread Starter Rajeev Rajan

    (@rajeevrf)

    Interesting. But when we deactivate the CAOS plugin, none of these js files(CAOS file, 2 external js files) load.
    So this has to be somehow related to this plugin right?
    Or does this have anything to do with WP Engine server?

    Thread Starter Rajeev Rajan

    (@rajeevrf)

    Hi Dan,

    Additional external scripts are wrapped inside the Google Tag Manager script in Google Console. Could this be a reason for these external scripts being present in the Page Speed Insights result and not in the View Source of the page when the page loads?

    One more question, This analytics.js is related to Universal Analytics right? In that case, do we really need to use this analytics.js since the GA4 is released and the Universal Analytics is no longer needed?

    Plugin Author DaanvandenBergh

    (@daanvandenbergh)

    Could this be a reason for these external scripts being present in the Page Speed Insights result and not in the View Source of the page when the page loads?

    Yup, that’s it. You should remove them.

    This analytics.js is related to Universal Analytics right? In that case, do we really need to use this analytics.js since the GA4 is released and the Universal Analytics is no longer needed?

    No. GA3 no longer exists, so the analytics.js isn’t needed anymore. Remove it.

    But when we deactivate the CAOS plugin, none of these js files(CAOS file, 2 external js files) load.

    When you say they don’t load, do you mean that they actually don’t load? Or do they not appear in your Pagespeed report? These are two different things, and only the latter makes sense, because when you disable CAOS, you’re no longer loading duplicate libraries (that’s why the Unused JS recommendation pops up)

    Thread Starter Rajeev Rajan

    (@rajeevrf)

    Yup, that’s it. You should remove them.

    I checked these 2 external scripts/tags inside the GTM. One of them is Analytics.js(GA3) and another one is the GA4 tag.
    So in this case, I should be removing the Analytics.js(GA3) code alone right?

    Also, one more doubt, If am using only GA4 then there is no need to use the GA4 inside GTM right? I can straight away use the GA4 code inside COAS plugin, isn’t it?

    Plugin Author DaanvandenBergh

    (@daanvandenbergh)

    You should also remove the GA4 one, because CAOS inserts a local copy of it.

    Plugin Author DaanvandenBergh

    (@daanvandenbergh)

    Also, one more doubt, If am using only GA4 then there is no need to use the GA4 inside GTM right? I can straight away use the GA4 code inside COAS plugin, isn’t it?

    Sorry, read pas this, but yes. Exactly!

    Thread Starter Rajeev Rajan

    (@rajeevrf)

    Thanks for the prompt replies, Dan. Much appreciated! Last 2 days, I have been reading your blogs and really those blogs has been an eye opener in this regard. Thanks!

    Plugin Author DaanvandenBergh

    (@daanvandenbergh)

    Cool! And no problem, that’s what I’m here for!

    Hi, sorry to disturb, but I wish to ask a related question: CAOS plugin works also with GTM ID? thanks

    Plugin Author DaanvandenBergh

    (@daanvandenbergh)

    Hi!

    CAOS doesn’t work with Gtm.js. Because the Google Tag Manager containers are unique to each user i.e. gtm.js will not work when hosted locally.

    Not to be confused with gtag.js, which is used for GA4 and works perfectly with CAOS.

    Hope it helps!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘In Google Page Speed Insights, GTM.js and JS file from CAOS folder both loading’ is closed to new replies.