Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

The Google Tag Manager Module

Parent Feed: 


Credits & Thanks

Thank you to Jim Berry for creating and maintaining the Google Tag Manager.

About the Google Tag Manager Module

Even though installing Google Tag Manager (GTM) on your Drupal site adds a layer of complexity, it is far more flexible (and powerful) than Google Analytics (GA) alone:

  • GTM can be set up to track advanced analytics, like Scroll Depth, Link Clicks, & Video Playback information.
  • GTM makes it easy to install custom tracking, like LinkedIn Insights or Facebook Pixel, without developer help.
  • GTM makes it easier to track transaction data, like order amount, which is essential for ROI calculations for your ad campaigns.

While not difficult, it does take a little time and effort to complete. Below are the steps Volacci goes through to do a Google Tag Manager install on all our clients’ Drupal websites.


Except in very special cases, you do not want to have both the Google Analytics and Google Tag Manager modules (or embedded code snippets) enabled on your site at the same time -- it can skew your Analytics. We recommend coordinating the Google Tag Manager installation & configuration with disabling your Google Analytics module. Contact your developer if you have questions on how Google Analytics is currently installed on your website -- or if you have multiple GA codes deployed, which can complicate things further.

Google Account Sign Ups

While we offer top level instructions in this section, you may need to find additional resources on the exact steps for signing up for these accounts. Google tends to change things periodically, so it’s best to find their step by step instructions. We've included links to their current instructions in this section.

  1. If you don’t already have one, sign up for a free Google Account.
    This will include a gmail account. If your company already uses Gmail for email, then you can use that Google Account. You’ll use this account for all the sign ups that follow.
  2. Sign up for Google Analytics for your website. When you complete this process, you will have created a property for your website on the GA admin Tracking Info > Tracking Code page. There will be a tracking code there that looks something like this:
     google tracking id sample
    We recommend opening a text editor and copying and pasting this tracking ID so you have it handy for your GTM set up. You’ll be using this text document again later, so leave it open.
  3. Create a Google Search Console (GSC) account for your website. This account will track organic (search) traffic to your website and can also be integrated into your Google Analytics (GA) account.
    For information on integrating GSC into your GA account, go here for their detailed instructions.
  4. Set up your website’s Google Tag Manager account.
     google tag manager set up screen
  5. Fill out the Account Name and Container name fields with your organization’s and website’s information, and select “Web” under Target platform.
  6. Click Create, agree to the terms of service and GDPR rules, and you should be presented with a pop up window containing two different code snippets. The top one will look like this:
     google tag manager snippet example
  7. Highlight the GTM-XXXXXXX number as we have in the example above.
  8. Copy and paste that number into the same text editor you placed your Google Analytics tracking ID.
  9. Deploy Google Analytics using Google Tag Manager by following Google's instructions. NOTE: You’ll need the UA-XXXXXXX-1 number you pasted into your text document for this step.
  10. Submit your XML Sitemap to Google by following Google's instructions.

Install The Google Tag Manager Module

You may need to get help from your developer with this process. Contact them should you have any questions or issues. Sending along a link to this page could help speed things up.

  1. Make a backup of your website. If something goes wrong, you’ll need to restore your website from a backup.
  2. Install the Google Tag Manager module available here: https://www.drupal.org/project/google_tag

    NOTE: Drupal module installation instructions can be found here: https://www.drupal.org/docs/extending-drupal/installing-modules

  3. Once the module is installed, make sure it’s enabled by going to the Extend page of your website: Click Manage > Extend or visit https://yourdrupalwebsite.com/admin/modules.
  4. In the search box, enter “google tag” to find the Google Tag Manager module.
     google tag manager drupal module installation
    • If the check box next to the module is checked, then the module has been enabled and is ready for configuration. Move on to Configure The Google Tag Manager Module.
    • If the check box next to the module is not checked, it will need to be enabled.

      If you have permissions to enable a module, you can select the check box next to the module, and click the Install button at the bottom of the page.

      NOTE: If you do not have permissions to enable the module, you’ll need to contact your web developer to enable it and give you the appropriate permissions to install and configure the GTM module.

Configure The Google Tag Manager Module

Make sure you have that text document handy that contains the GTM container ID that was generated above.

  1. On your Drupal site, go to Manage > Configuration > System > Google Tag Manager or visit http:///admin/config/system/google-tag in your browser.
    This will take you to the Google Tag Manager containers page.
    google tag manager containers
  2. Click on the + Add container button. This will take you to the Add container page.Drupal google tag manager containers creation page
  3. Enter a relevant name in the Label field.
  4. In the Container ID field, enter the Container ID  (GTM-XXXXXXX) you copied from Google Tag Manager.
  5. Leave all other settings at their default.
  6. Click the Save button at the bottom of the page.

Testing Your Installation

We recommend testing to make sure your Google Tag Manager is properly installed and configured. Here at Volacci, we test in several different ways using the Chrome browser. If you use a different browser, some of these methods may not work.

  1. Go into the Google Tag Manager workspace for your website and follow Google's instructions for testing with Preview mode.
  2. Install Google Tag Assistant within your Chrome browser. 

    For additional information on how to use Google Tag Assistant for testing and troubleshooting your Google product installations, visit Google's support page

There you have it. You should be all set to gather Google Analytics data and make deployment of 3rd party scripts to your website much easier.

We always try to make sure our posts are as accurate and up to date as possible. If you find something is wrong, or you have a question, please feel free to contact us with any questions or feedback you might have.

And remember, Volacci stands ready to help you implement your Google Tag Manager and Google Analytics should you need us to.

Did you like this walkthrough? Please tell your friends about it!

twiter social icon linkedin social icon pinterest social icon

Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web