• Members 35 posts
    Sept. 21, 2023, 10:52 a.m.

    These code snippets were inserted into the pages of a WordPress site, either by the theme or Site Kit, after I performed the GA upgrade from Universal Analytics to GA4. I'd like to confirm if they appear to be correct.

    Additionally, if the Site Kit plugin is installed, is it still necessary to manually add GA code via a WordPress theme, or does Site Kit handle all of this for us?

    <head>
    <!-- Google Analytics opt-out snippet added by Site Kit -->
    <script type="text/javascript">
    window["ga-disable-UA-48673498-1"] = true;
    </script>
    <script type="text/javascript">
    window["ga-disable-G-SHQPQ85CD4"] = true;
    </script>
    <!-- End Google Analytics opt-out snippet added by Site Kit -->
    <!-- Google Analytics snippet added by Site Kit -->
    <script type='text/javascript' src='www.googletagmanager.com/gtag/js?id=UA-48673498-1' id='google_gtagjs-js' async></script>
    <script type='text/javascript' id='google_gtagjs-js-after'>
    window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}
    gtag('set', 'linker', {"domains"🙁"foo.com.au"]} );
    gtag("js", new Date());
    gtag("set", "developer_id.dZTNiMT", true);
    gtag("config", "UA-48673498-1", {"anonymize_ip":true});
    gtag("config", "G-SHQPQ85CD4");
    </script>
    <!-- End Google Analytics snippet added by Site Kit -->
    </head>

  • Mod
    Sept. 21, 2023, 10:56 a.m.

    I can verify that the code snippets you provided appear to be correct! The initial snippets pertain to opt-out configurations, intended for administrators who don't want their own site visits to be tracked. You can configure these settings within the Site Kit plugin's Analytics settings.

    The subsequent snippets, located below the gtag.js reference, encompass both your Universal Analytics (UA-) and Google Analytics 4 (GA4) code.

    In summary, everything appears to be in order! You can also cross-reference the code by visiting the Site Kit website, where they list the code added by the plugin to users' websites, provided users have permitted the plugin to insert Analytics code for them. You can find this information here: sitekit.withgoogle.com/documentation/using-site-kit/site-kit-modules-and-your-sites-source-code/

    Regarding your question about whether it's necessary to add GA code via a WordPress theme when the Site Kit plugin is installed – the answer is no! Site Kit takes care of inserting the code for users, regardless of the theme in use. So, if you've allowed Site Kit to insert the code for you, there's no need for manual insertion of Google Analytics code.

    I hope this clarifies things for you!