With each Google service that you connect in Site Kit, Site Kit will add code snippets to your website to facilitate this connection. To view these snippets in your site’s code, right-click on any blank part of your site and select View source or View page source from the pop-up menu that appears.

The snippets that Site Kit places for each service are summarized below. Note that the snippet examples below may be modified by third-party plugins, which can sometimes remove Site Kit-added comments or otherwise change the default plugin-placed snippets.

Search Console

During Site Kit setup, the plugin will verify ownership and register your site on Search Console. If your site is not already verified on Search Console, the plugin will verify ownership using the file upload method. This doesn’t add any code to the front-end of your site. 
If the file upload method fails, which can be the case for some hosting providers, the plugin will use the meta tag verification method to verify ownership. The code will look similar to the below:

<meta name="google-site-verification" content="......." />

Google Analytics

When Google Analytics is connected using Site Kit, the plugin can insert a Google Analytics tag on your site. 

The example snippet below shows a default Google Analytics snippet as inserted via Site Kit. This snippet is inserted within the <head> tag per Google Analytics placement guidelines and includes both a Universal Type (UA) snippet along with a Google tag (with a GT- prefix) snippet. This Google tag snippet is used to connect your site with your selected Google Analytics 4 (GA4) property. If you had a GA4 snippet placed prior to the release of the new Google tag, you may notice a GA4 snippet (with a G- prefix) in place of the Google Tag snippet. You’ll find out more about how Site Kit uses the Google tag snippet for GA4 by visiting this guide.  

<!-- Google Analytics snippet added by Site Kit -->
<script type='text/javascript' src='https://www.googletagmanager.com/gtag/js?id=G-481MX*****' 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":["example.com"]} );
gtag("js", new Date());
gtag("set", "developer_id.dZTNiMT", true);
gtag("config", "GT-481MX*****");
</script>
<!-- End Google Analytics snippet added by Site Kit -->

In addition to the standard Site Kit-placed Google Analytics snippet, if the Exclude from Analytics setting is turned on in Settings > Site Kit > Connected Services > Analytics, an opt-out snippet will also be added. This opt-out snippet is to ensure that logged-in users and/or users who can write posts are not included in Google Analytics tracking. This snippet will only be visible in the site’s source code when viewed by these affected users.

An example of this snippet can be found below, added to both a UA property and a GA4 property (via Google tag property). This snippet is placed within the site’s <head> tags.

<!-- Google Analytics opt-out snippet added by Site Kit -->
<script type="text/javascript">
window["ga-disable-UA-1838*****-1"] = true;
</script>
<script type="text/javascript">
window["ga-disable-GT-481MX*****"] = true;
</script>
<!-- End Google Analytics opt-out snippet added by Site Kit -->

AMP

If you’re an AMP user and you’ve allowed Site Kit to insert your Google Analytics snippet, an amp-analytics script snippet will be added to your AMP URLs, within the <head> tag:

<script async nomodule src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js" crossorigin="anonymous" custom-element="amp-analytics"</script> 

In addition, the snippet below will also be added to your site’s AMP URLs within the <body>element. This snippet references a user’s connected Universal Analytics and Google Analytics 4 property. A user’s opt-out configuration status will also be added within this snippet.

<amp-analytics type="gtag" data-credentials="include" class="i-amphtml-layout-fixed i-amphtml-layout-size-defined" style="width:1px;height:1px" i-amphtml-layout="fixed"><script type="application/json">{"optoutElementId":"__gaOptOutExtension","vars":{"gtag_id":"UA-1511*****-1","config":{"UA-151145400-1":{"groups":"default","linker":{"domains":["example.com"]}},"G-7TG3MD6C9G":{"groups":"default","linker":{"example.com"]}}}}}</script>

AdSense

If you choose to allow Site Kit to insert AdSense code on your site, a snippet similar to the below will be inserted. This snippet will include your own AdSense publisher ID, and the Site Kit AdSense for Platforms ID. This is added to the <head> tag of your site. 

<!-- Google AdSense snippet added by Site Kit -->
<script async="async" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-34671618896******&host=ca-host-pub-2644536267******" crossorigin="anonymous" type="text/javascript"></script>
<!-- End Google AdSense snippet added by Site Kit -->

Site Kit will also insert the following snippet to the <head> tag, referencing a Site Kit AdSense for Platforms publisher ID. This is used to indicate to AdSense that Site Kit was used to place AdSense code on your site.

<!-- Google AdSense snippet added by Site Kit -->
<meta name="google-adsense-platform-account" content="ca-host-pub-2644536267352236">
<meta name="google-adsense-platform-domain" content="sitekit.withgoogle.com">
<!-- End Google AdSense snippet added by Site Kit -->

AMP

If you’re an AMP user, Site Kit can also insert the AMP version of your AdSense code. This will result in the <amp-auto-ads> script being placed within your site’s <head> tag on AMP URLs. This appears as below.

<script async nomodule src="https://cdn.ampproject.org/v0/amp-auto-ads-0.1.js" crossorigin="anonymous" custom-element="amp-auto-ads"></script>>

The following snippet will also be added to the <head> tag on AMP URLs, referencing a Site Kit AdSense for Platforms publisher ID. This is used to indicate to AdSense that Site Kit was used to place AdSense code on your site.

<meta name="google-adsense-platform-account" content="ca-host-pub-2644536267352236"><meta name="google-adsense-platform-domain" content="sitekit.withgoogle.com">

The below snippet will be added on AMP URLs, within the <body> element. This snippet references a user’s individual AdSense account ID.

<!-- Google AdSense AMP snippet added by Site Kit -->
<amp-auto-ads type="adsense" data-ad-client="ca-pub-34671618896*****" class="i-amphtml-layout-container" i-amphtml-layout="container"></amp-auto-ads>
<!-- End Google AdSense AMP snippet added by Site Kit -->

Google Tag Manager

NOTE: Site Kit will give you the option during setup to have the plugin place the Google Tag Manager code snippet. You can also turn off the Site Kit-placed snippet after it has been placed. 

If you choose to insert a Google Tag Manager container on your site via Site Kit, a snippet similar to the below will be inserted. This will appear within your sites <head> element and will include your connected Google Tag Manager ID.

 <!-- Google Tag Manager snippet added by Site Kit -->
<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-5C3****' );
</script>
<!-- End Google Tag Manager snippet added by Site Kit -->
 

AMP

If you’re an AMP user and you’ve allowed Site Kit to insert your Google Tag Manager snippet, the below <amp-analytics> script snippet will be added to your AMP URLs, within the <head> tag. 

<script async nomodule src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js" crossorigin="anonymous" custom-element="amp-analytics"</script>

Within the <body> element, a snippet similar to the below will appear, referencing your site’s AMP container ID. 

<!-- Google Tag Manager AMP snippet added by Site Kit -->
<amp-analytics config="https://www.googletagmanager.com/amp.json?id=GTM-KT*****" data-credentials="include" class="i-amphtml-layout-fixed i-amphtml-layout-size-defined" style="width:1px;height:1px" i-amphtml-layout="fixed"><script type="application/json">{"optoutElementId":"__gaOptOutExtension"}</script></amp-analytics>
<!-- End Google Tag Manager AMP snippet added by Site Kit -->

Optimize

NOTE: Site Kit will give you the option during setup to have the plugin place the Optimize code snippet. You can also turn off the Site Kit-placed snippet after it has been placed. 

The Google Analytics module must already be connected within Site Kit in order to connect the Optimize module. When both modules are connected, the Optimize account ID is attached to a user’s Google Analytics snippet. This can be seen below in a summary of a Google Analytics snippet. 

gtag("config", "UA-18386*****-1", {"anonymize_ip":true,"optimize_id":"GTM-WD*****"}); 

If the anti-flicker snippet configuration has been enabled in Site Kit > Settings > Connected Services > Optimize, the below snippet will also be added.

<!-- Anti-flicker snippet added by Site Kit -->
<style>.async-hide { opacity: 0 !important} </style><script type="text/javascript">
(function(a,s,y,n,c,h,i,d,e){s.className+=' '+y;h.start=1*new Date;
h.end=i=function(){s.className=s.className.replace(RegExp(' ?'+y),'')};
(a[n]=a[n]||[]).hide=h;setTimeout(function(){i();h.end=null},c);h.timeout=c;
})(window,document.documentElement,'async-hide','dataLayer',4000,
{'GTM-WD*****':true});
</script>

<!-- End Anti-flicker snippet added by Site Kit -->

Site Kit in the Admin Bar

If you have the WordPress Admin Bar enabled and the Site Kit tab is present, the below code snippet will appear in your site’s source code for logged-in users only. This will be placed within your site’s <body> element.

<li id='wp-admin-bar-google-site-kit' class="menupop googlesitekit-wp-adminbar">
        <a class='ab-item' href='#'>
        <span class="googlesitekit-wp-adminbar__icon"></span> 
        <span class="googlesitekit-wp-adminbar__label">Site Kit</span>
        </a>		
    <div class="googlesitekit-plugin ab-sub-wrapper">
        <noscript>
            <div class="googlesitekit-noscript notice notice-warning">
                <div class="mdc-layout-grid">
                    <div class="mdc-layout-grid__inner">
                       <div class="mdc-layout-grid__cell mdc-layout-grid__cell--span-12">
                            <p class="googlesitekit-noscript__text">
									The Site Kit by Google plugin requires JavaScript to be enabled in your browser.								</p>
					    </div>
				    </div>
			    </div>
		    </div>
	    </noscript>
		
        <div id="js-googlesitekit-adminbar" class="googlesitekit-adminbar">	
		    <section id="js-googlesitekit-adminbar-modules" class="googlesitekit-adminbar-modules"></section>
	    </div>
		
    </div>
</li>