---
# System prepended metadata

title: Google Tag Manager
tags: [Site Settings]

---

---
title: Google Tag Manager
tags: Site Settings
---

# Google Tag Manager

The Drupal CMS allows for easy addition of a GTM code. GTM codes are generated separately from Drupal, site owners should contact their analytics team contact to obtain the site specific code.

## Resources

### CMS Instructions

#### Google Tag Manager Administration

Google Tag Manager (GTM) allows you to deploy analytics and measurement tag configurations from a web-based user interface (hosted by Google) instead of requiring administrative access to your website.

Here is the full code snippet for Google Tag Manager:

```xml=
<!-- 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-K7B7TH4');</script>
<!-- End Google Tag Manager -->
```

And the below snippet should be present on top of `<body>` tag

```xml=
<!-- Google Tag Manager (noscript) -->
<noscript><iframe name="GTM-iframe" src="https://www.googletagmanager.com/ns.html?id=GTM-K7B7TH4"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
```

Please note that only the container ID `GTM-K7B7TH4` will be used on the config page in the CMS.

Site administrators can make changes to the Google Tag Manager container ID leveraging the Drupal Admin interface as follows.

**Step 1** : Navigate to the **Structure** menu and click **Config pages**:

![Configuration Menu Item](https://hackmd.io/_uploads/Skfy6S3Qq.png)

On the Config Pages screen, click the **Edit** button under Operations for the **GTM** library:

![Configuration Library](https://hackmd.io/_uploads/r1mC6pxP9.png)

**Step 2:** On the GTM configuration page, fill in the GTM code and click **Save**: 

![GTM Configuration Page](https://hackmd.io/_uploads/Byu71vrVc.png)






