Title: gtag Javascript unused?
Last modified: February 27, 2021

---

# gtag Javascript unused?

 *  Resolved [djeah](https://wordpress.org/support/users/djeah/)
 * (@djeah)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/gtag-javascript-unused/)
 * Hi,
 * I know few users have pointed out that the Javascripts inserted is slowing down
   the page, but my question is different.
    When Pagespeed says that the below Javascript
   is unused and asking me to remove it, I am wondering whether it is really not
   used?
 * `https://www.googletagmanager.com/gtag/js?id=UA-177XXXXXX-1`
 * What confuses me more is that if I disable grouping of Javascript files on my
   site, I do not see the `Remove unused JavaScript` recommendation at all. But 
   if I enable grouping of Javascript files, the number of requests count drops 
   from some 67 to 43, but I see this script along with the grouped javascript created
   by the plugin as unused.
 * I have search console and analytics activated via Site Kit.
    -  This topic was modified 5 years, 3 months ago by [djeah](https://wordpress.org/support/users/djeah/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fgtag-javascript-unused%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 10 replies - 1 through 10 (of 10 total)

 *  Plugin Support [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * (@jamesosborne)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/gtag-javascript-unused/#post-14115424)
 * Thanks for reaching out. The Site Kit placed Analytics snippet is required in
   order for your site to record site visits, although it should have minimal impact
   on site performance.
 * While not being an expert on PageSpeed Insights my guess is that as because your
   Analytics snippet has slight differences places to the standard snippet placed
   via Site Kit some of this JavaScript may me marked as unused. When checking your
   site source code I notice a `siteground-async=1` reference within your Analytics
   snippet.
 * Have you submitted the same question to the product experts at the Analytics 
   Help Center? They should have more insights on this than we can provide here.
   Alternatively you could try and temporarily deactivate any your SG Optimizer 
   or any other optimization plugin that may be altering the snippet before checking
   once more.
 * > What confuses me more is that if I disable grouping of Javascript files on 
   > my site, I do not see the Remove unused JavaScript recommendation at all.
 * This isn’t a feature of Site Kit, so I can’t be sure how another plugin combines
   may alter existing Site Kit placed snippets. What plugin are you using, or where
   do you see this configuration, I’m happy to check this for you if you share more
   details.
 *  Thread Starter [djeah](https://wordpress.org/support/users/djeah/)
 * (@djeah)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/gtag-javascript-unused/#post-14135994)
 * Hi [@jamesosborne](https://wordpress.org/support/users/jamesosborne/) ,
 * I am using Siteground and breeze plugin. But the javascript minification and 
   grouping was enabled only from breeze, as I disabled it from the SG optimizer
   now.
 * However, having done this, the unused gtag only shows up in the mobile version
   of my site and not in desktop version in Pagespeed now.
 *  Plugin Support [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * (@jamesosborne)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/gtag-javascript-unused/#post-14139570)
 * Thanks for the additional insights. If you temporarily deactivate any Breeze 
   and SG Optimizer configurations that impact your Analytics snippet I suspect 
   you won’t encounter the same unused JavaScript notice. Let me know once you’ve
   temporarily removed this and I’m happy to check your site once more.
 * Note that this shouldn’t have any impact performance, I found some [additional insights](https://github.com/GoogleChrome/lighthouse/issues/10872)
   in the Lighthouse GitHub repository in relation to this (Lighthouse is the technology
   used for PageSpeed Insights). This notice can occur when not all of a JavaScript
   snippet is determined as used based on PageSpeed Insights logic.
 * > However, having done this, the unused gtag only shows up in the mobile version
   > of my site and not in desktop version in Pagespeed now.
 * That does sound unusual, although I suspect some of the additional JavaScript
   may be based on different screen dimensions or devices. It might be interesting
   to know if this also occurs without any additions to the default snippet as placed
   via Site Kit – again with the SiteGround or Breeze plugins temporarily deactivated.
 *  Thread Starter [djeah](https://wordpress.org/support/users/djeah/)
 * (@djeah)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/gtag-javascript-unused/#post-14147907)
 * Hi [@jamesosborne](https://wordpress.org/support/users/jamesosborne/) ,
 * I went through the link and looked like breeze wasn’t functioning properly for
   the JS and CSS. Over the weekend I optimized my site further to get a decent 
   score using Autoptimize. I will not be using the JS/CSS options of Breeze and
   SG Optimizer now as I am getting good speed and scores, except on the mobile 
   using Autoptimize.
 * In Autoptimize doesn’t matter if I aggregate the files, or not, both :
    `https://
   www.googletagmanager.com/gtag/js` and `https://www.googletagmanager.com/gtag/
   js?id=UA-1778xxxxx-1&l=dataLayer&cx=c` show up in unused category in mobile and`
   https://www.googletagmanager.com/gtag/js` as render blocking both in mobile and
   desktop.
 * When I checked the source code of the page I do not see any async or defer property
   for `https://www.googletagmanager.com/gtag/js` and if I force it to load with
   either of that property using a plugin, it breaks the site.
 *  Plugin Support [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * (@jamesosborne)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/gtag-javascript-unused/#post-14155940)
 * Apologies for the late response. When Site Kit places your tags it does include
   an async reference, you’ll find a typical Site Kit placed insert [here](https://i.imgur.com/FOEpe5h.png).
 * From inspecting your site once more I see a Tag Manager request although this
   snippet placement is not placed via Site Kit.
 * If there are any modifications to the snippet via any other plugins this may 
   be resulting in the unused JavaScript notice within PageSpeed Insights. You’ll
   find a guide on this [here](https://web.dev/unused-javascript/). Note that also
   if you’re using Google Tag Manager – connected via Site Kit or manually it’s 
   also possible you may encounter this notice depending on the tags you have inserted.
 * As we’re limited to Site Kit plugin support can you confirm all your Site Kit
   dashboards are working as expected? If not we can do some troubleshooting with
   your additional optimization plugins to ensure it’s working as expected.
 *  Thread Starter [djeah](https://wordpress.org/support/users/djeah/)
 * (@djeah)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/gtag-javascript-unused/#post-14156823)
 * It was just yesterday that I setup a new GA4 analytics as I was using UA. I added
   the new GA4 using Site Kit Tag Manager. So now I have both UA and GA4 on my site.
 * One more info is that I recall having specified configurations in the Complianz
   Cookie plugin following the steps in this URL [https://complianz.io/configuring-google-site-kit/](https://complianz.io/configuring-google-site-kit/),
   where I followed the 2nd approach “Google Site Kit will add the Analytics snippet.
   Complianz handles consent only.”
    -  This reply was modified 5 years, 3 months ago by [djeah](https://wordpress.org/support/users/djeah/).
 *  Plugin Support [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * (@jamesosborne)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/gtag-javascript-unused/#post-14156906)
 * Nice work getting both a UA and GA4 property added to your site, that way you
   can use the Site Kit dashboards while also making use of the newer GA4 Tag.
 * In relation to the Complianz documentation thanks for sharing. I’ve tested the
   same plugin previously although an older version, so I can’t be sure if any additional
   may be triggering any unused JavaScript notice. I did check your site [once more](https://lighthouse-dot-webdotdevsite.appspot.com//lh/html?url=https%3A%2F%2Fwww.myheartontravel.com%2F)
   and see that the unused JavaScript indicates this as a minor opportunity, that
   doesn’t direct impact your performance score. If you’re looking to improve your
   performance score you can follow the suggestions on the [same report](https://lighthouse-dot-webdotdevsite.appspot.com//lh/html?url=https%3A%2F%2Fwww.myheartontravel.com%2F),
   or use PageSpeed Insights.
 *  Thread Starter [djeah](https://wordpress.org/support/users/djeah/)
 * (@djeah)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/gtag-javascript-unused/#post-14158091)
 * Thanks [@jamesosborne](https://wordpress.org/support/users/jamesosborne/) . One
   last question. If I setup both GA4 and UA with the same Google Tag Manager container
   ID, will that work? I see that if I connect only google tag manager, it inserts
   an iframe on every page.
 * But the below code is present only on the homepage:
 *     ```
       <script>( function( w, d, s, l, i ) {
       	w[l] = w[l] || [];
       	w[l].push( {'gtm.start': new Date().getTime(), event: 'gtm.js'} );
       	var f = d.getElementsByTagName( s )[0],
       		j = d.createElement( s ), dl = l != 'dataLayer' ? '&l=' + l : '';
       	j.async = true;
       	j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
       	f.parentNode.insertBefore( j, f );
       } )( window, document, 'script', 'dataLayer', 'GTM-XXXXXX );</script>
       ```
   
 *  Plugin Support [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * (@jamesosborne)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/gtag-javascript-unused/#post-14160499)
 * No problem at all. You can setup a GA4 and UA property together without Tag Manager
   if you wish, you’ll find a manual code snippet example displaying both in [this guide](https://developers.google.com/analytics/devguides/collection/ga4/basic-tag?technology=gtagjs).
   Site Kit will recognize your UA snippet during Analytics setup, therefore not
   inserting the snippet for you_ (Ensure you have the option toggled off for Site
   Kit to insert your snippet after revisiting the Analytics module settings screen)_.
 * Let me know if you have any further questions on the above.
 *  Plugin Support [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * (@jamesosborne)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/gtag-javascript-unused/#post-14195466)
 * As we didn’t receive a response I’ll mark this as resolved. Feel free to open
   a [new support topic](https://wordpress.org/support/plugin/google-site-kit/#new-post)
   if you continue to encounter issues, or reopen this topic and we’d be happy to
   assist.

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘gtag Javascript unused?’ is closed to new replies.

 * ![](https://ps.w.org/google-site-kit/assets/icon-256x256.png?rev=3141863)
 * [Site Kit by Google - Analytics, Search Console, AdSense, Speed](https://wordpress.org/plugins/google-site-kit/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/google-site-kit/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/google-site-kit/)
 * [Active Topics](https://wordpress.org/support/plugin/google-site-kit/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/google-site-kit/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/google-site-kit/reviews/)

## Tags

 * [cache](https://wordpress.org/support/topic-tag/cache/)
 * [gtag](https://wordpress.org/support/topic-tag/gtag/)

 * 10 replies
 * 2 participants
 * Last reply from: [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * Last activity: [5 years, 2 months ago](https://wordpress.org/support/topic/gtag-javascript-unused/#post-14195466)
 * Status: resolved