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 code 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 code snippets that Site Kit places for each service are summarized below. Note that the code 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 code 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 Ads

When Google Ads is connected using Site Kit, the plugin can insert a Google Ads code snippet on your site. The two example code snippets below show a default Google Ads snippet with and without a connected Analytics module as inserted via Site Kit. These code snippets are inserted within the <head> tag per Google placement guidelines. 

Without Analytics module connected:

<!-- Google Ads snippet added by Site Kit -->
<script src="https://www.googletagmanager.com/gtag/js?id=AW-12345***" id="google_gtagjs-js" async></script>
<script id="rgoogle_gtagjs-js-after">
window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}
gtag("js", new Date());
gtag("set", "developer_id.dZTNiMT", true);
gtag("config", "AW-12345***");
</script>

With Analytics module connected:

<!-- Google Analytics snippet added by Site Kit -->
<script src="https://www.googletagmanager.com/gtag/js?id=GT-NGS9***" id="google_gtagjs-js" async></script>
<script id="google_gtagjs-js-after">
window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}
gtag("set","linker",{"domains":["YOURDOMAIN"]});
gtag("js", new Date());
gtag("set", "developer_id.dZTNiMT", true);
gtag("config", "GT-NGS9***");
gtag("config", "AW-12345***");
</script>

Google Analytics

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

The example code snippet below shows a default Google Analytics snippet as inserted via Site Kit. This code snippet is inserted within the <head> tag per Google Analytics placement guidelines and includes a Google tag (with a GT- prefix) code snippet. This Google tag code snippet is used to connect your site with your selected Google Analytics 4 (GA4) property. If you had a GA4 code snippet placed prior to the release of the new Google tag, you may notice a GA4 code snippet (with a G- prefix) in place of the Google tag code snippet. You’ll find out more about how Site Kit uses the Google tag code 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 code snippet, if the Exclude from Analytics setting is turned on in Settings > Site Kit > Connected Services > Analytics, an opt-out code snippet will also be added. This opt-out code snippet is to ensure that logged-in users and/or users who can write posts are not included in Google Analytics tracking. This code snippet will only be visible in the site’s source code when viewed by these affected users.

An example of this code snippet can be found below, added to a GA4 property (via Google tag property). This code 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-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 code 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 code snippet references a user’s connected Google Analytics 4 property. A user’s opt-out configuration status will also be added within this code 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":"G-481MX*****","config":{"G-481MX*****":{"groups":"default","linker":{"domains":["mysite.com"]},"googlesitekit_post_type":"post","googlesitekit_post_date":"20231019","googlesitekit_post_author":7,"googlesitekit_post_categories":"203"}}}}</script>

AdSense

If you choose to allow Site Kit to insert AdSense code on your site, a code snippet similar to the below will be inserted. This code 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 code 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 the AdSense code snippet on your site. This code snippet will be inserted if the AdSense module is connected, even if you choose not to allow Site Kit to insert AdSense code on your site.

<!-- Google AdSense meta tags 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 meta tags added by Site Kit -->

AMP

If you’re an AMP user, Site Kit can also insert the AMP version of your AdSense code snippet. 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 code 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 code snippet will be added on AMP URLs, within the <body> element. This code snippet references a user’s individual AdSense account ID.

<amp-auto-ads type="adsense" data-ad-client="ca-pub-34671618896*****" class="i-amphtml-layout-container" i-amphtml-layout="container"></amp-auto-ads> 

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 code 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 code 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 -->

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>