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

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

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 Analytics 4 (GA4) type snippet.

<!-- Google Analytics snippet added by Site Kit -->
<script type='text/javascript' src='https://www.googletagmanager.com/gtag/js?id=UA-1838*****-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":["example.com"]} );
gtag("js", new Date());
gtag("set", "developer_id.dZTNiMT", true);
gtag("config", "UA-1838*****-1", {"anonymize_ip":true});
gtag("config", "G-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. 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-G-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 property. At this time, only the UA property type is supported in AMP. A user’s opt-out configuration status will also be added within this snippet.

<!-- Google Analytics AMP snippet added by Site Kit-->
<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-151*****-1":{"groups":"default","linker":{"domains":["example.com"]}}}}}</script></amp-analytics>
<!-- End Google Analytics AMP snippet added by Site Kit -->

AdSense

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

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 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******" crossorigin="anonymous" type="text/javascript"></script>
<!-- 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 below snippet will also 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 -->