Adding GTM to a site
This article details the various methods by which we can add a GTM container to a site. This is likely to change in the near future as we continue to update our methods for managing third party scripts.
Identify type of GTM script
Before we place the script, we want to determine which kind of GTM script we are being provided. We can pretty easily tell this from how the script looks. Because the dealer may not always forward over the appropriate instructions, looking at the format can help tell you how to set it up. (Don’t be afraid to go back to the dealer and ask for the documentation or instructions if it’s not clear, though!)
Head Only
Coming soon
Head & Body
This type of script has two “sections” to it – a section that goes in the header scripts, and a section that goes in the “body” of the site.
Example:
<!-- Google Tag Manager --> <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-#######');</script>
<!-- End Google Tag Manager -->
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-####### " height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
As you can see, there is a section labeled “Google Tag Manager” and one that is labeled “Google Tag Manager (noscript)”. We will be placing each of these in two separate locations.
The first section, the regular Google Tag Manager script, will go in the Header scripts. Navigate to the domain’s Developer tab, and paste this at the bottom of the Page Head Html area.
Save & Publish the page, and then we’ll need to add the second noscript part.
Once you’ve copied the noscript section to your clipboard, you’ll want to navigate to the snippets folder and find the header snippet (on Sitesmith sites, this will be in a folder within the Snippets folder called Header, on older sites this may simply be a snippet called header-content or similar). Open the Code Editor for the snippet.
At the very top of the snippet, before all other content, paste the noscript code here.
Once you have pasted it, click “Ok” to exit the Code Editor, and then Save & Publish.
You have now installed the GTM!