Upgrade Your Drupal Skills

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

See Advanced Courses NAH, I know Enough

Moving from Google Analytics to Google Tag Manager on Drupal Sites

Parent Feed: 

The value of Google Analytics is a no brainer. Everyone knows the importance of tracking user trends on their website and understands the power behind the insights Google can help provide.

More and more of our customers are also starting to see the advantages that Google Tag Manager can provide as well, and want to start using it on their existing websites without waiting for a complete site rebuild. Within Continuous Development Agreements, we have been helping many organizations navigate the transition from Google Analytics to Google Tag Manager. Here’s an overview of why you might want to do this, and how you can accomplish it in a timely and effective manner.

What Google Tag Manager Offers

Before we talk about what Google Tag Manager does, it’s important to distinguish it from Google Analytics. It’s not an upgrade or an improvement; the two are fundamentally different. If you add Google Tag Manager to your site, it doesn’t mean that Google Analytics goes away.

Just like the name suggests, Tag Manager is a tool that allows website administrators more control over the snippets, integrations, tracking tools, and other scripts that run on their website when users come to visit. Tag Manager offers no analytics, insights, or tracking on its own. So you’ll still go to the same Analytics dashboard for user statistics if you’ve decided to add Google Tag Manager to your site - which is good! It means website owners don’t need to relearn a system to get the same information.

So, what’s all the fuss about Tag Manager for then, if Analytics stays the same? Tag Manager does offer some tools that allow website managers to track some even more granular information about user behavior. For instance:

  • Analytics may be able to tell you where users come from before they hit a particular page, and

  • Tag Manager can help track the effectiveness of a specific button on a particular page to get users to convert to a desired action.

As you can see, Tag Manager is very useful if you have multiple calls to action across the site. Even within a single page, Tag Manager can help you figure out which buttons, blocks, and calls to action are the most effective.

Possibly even more helpful though, is Tag Manager’s ability to add multiple tracking scripts to a page of the website, or globally across the website. In the past, additional JavaScript tags needed to be added into a website’s codebase one by one with help from a development team. Depending on how many other priority items managers had stacked up for sprints, it could take several weeks to get these simple tags out to the production site.

With Tag Manager, site owners have the ability to add integrations with other services onto their website without any custom code from the development team. They can add these scripts within the Tag Manager console and publish them independently all in a single day if needed. Some practical examples include:

  • Cookie acceptance banners provided by third party sites (very useful when GDPR compliance deadlines were looming)

  • Chat applications that overlay the site and provide

  • Social media integration, such as LinkedIn tracking

  • Marketing automation tools that help track potential leads

We’ve seen this lead to a great separation of responsibilities, where our development teams can focus on what they do best - maintaining the Content Management System - while empowering website owners to own the integration points between the website and their partnerships with other services that do what they do best. It means customers are getting the most out of their contracts with us, and not adding unnecessary overhead on the products they choose to augment the website.

How To Set Up Google Tag Manager On Your Website

There is a short and long explanation of how to do this, and we’ll give you both. The basic information you need goes like this:

  • Create a Google Tag Manager Account and Container

  • Install the module for your Drupal 7 or 8 website: https://www.drupal.org/project/google_tag

  • Add your Google Analytics ID into Google Tag Manager

  • Configure the Google Tag Manager Module on your website

  • Disable the Google Analytics Module (tracking may not work right otherwise)

We always recommend that you add any modules to the codebase with help from a development team that can make sure your code is all properly version controlled.

With that disclaimer, if you are manually managing your own site completely through the Drupal Admin User Interface it’s possible to add the new module in manually and disable the old one manually as well. If this is the case for you, we hope that the following information will help you see great results quickly, and that you’ll contact us when you’re ready to get a development team involved in maintaining your site.

Getting Started With Google Tag Manager (The long version!)

Step one is the same: you’ll need a Google Account of course. You can visit their splash page at https://marketingplatform.google.com/about/tag-manager/ if you’d like to, or go straight to https://tagmanager.google.com to get started. Once you are there and logged in, you’re looking for the “Create Account” button up near the top of the screen.

Each account can have multiple “containers.” A specific container connects with a specific website.

For instance, you may choose to create one container for your live website and another container for your non-production sites so that you can use sandbox accounts on development and staging environments. Each container will have a unique ID formatted like GTM-XXXXXXX.

Install The Module

As noted above, if you absolutely must you can do this manually, though it is far better (and safer) to have a Drupal development agency add the module to your codebase and enable it on the live site. Depending on how quickly you want to get this done, you can make a brief stop in a non-production environment to try all of these steps and make sure tracking is working correctly before activating everything on the live site.

Configure Google Tag Manager to Trigger Google Analytics

There are a few ways to do this, and part of understanding them will be learning the Google Tag Manager interface itself. You’ll definitely want to have your Analytics tracking code handy, formatted like UA-#######-#. If you get stuck, the Google Support system is extensive. Articles like https://support.google.com/tagmanager/answer/6106716?hl=en can help guide those learning their way around.

Again, this is a good place to use different analytics accounts for non-production sites if you so choose.

Configure the Google Tag Manager module in Drupal

Get your container ID ready (GTM-XXXXXXX) and log into your website. Going to /config/system/google_tag will get you to the configuration page in both Drupal 7 and Drupal 8, or you can find it the long way by navigating your list of modules or the configuration page. The configuration screen is pretty simple, but does provide some handy options if you want to exclude Tag Manager from running in particular circumstances. This looks similar for both versions of Drupal as well:

Drupal 7

Drupal 8

Don’t forget to hit save when you’re done.

Disable Google Analytics Module And Other Cleanup

If you don’t disable the Google Analytics module on your website, the GA tracking ID may be duplicated in your code, which can lead to incorrect analytics information (maybe double, or may fail to track sometimes). That’s reason enough on its own, but we’d be remiss not to take this opportunity to remind website owners that it’s always best to disable and uninstall modules that are no longer in use. Keep those codebases lean!


It’s also worth mentioning that just like with Google Analytics, if you plan to start using Google Tag Manager to manage all of your integrations, you’ll need to remove any scripts that have already been hard-coded into the site before you add them to Google Tag Manager and start having them run that way. We’ve seen cases where trying to load a script via Tag Manager and directly through the website code at the same time will prevent the integration/tracking from running at all.

Is It Worth It?

All those setup steps may sound like more work than it’s worth at first, but this is definitely one of those things that sounds scarier than it really is. Typically, our customers are able to use a few hours from their ongoing improvement contracts with us to prioritize the module installation as a small part of a normal two-week sprint, and then follow up with removing the old module code from their site in the sprint that follows.

When it comes to the time investment required for your team, there is a bit of a learning curve with Google Tag Manager, but generally within the first month of making the change, website owners become comfortable with the new system and start impressing their stakeholders and direct reports with all of the ways they can use it to enhance the site. Once the setup is complete you’ll look back and wonder why it ever seemed complex, and enjoy how managing integrations on your site has become a breeze.

Are you looking for help with analytics, tracking, and site performance improvements? Contact our team to learn how we can help you advance your marketing goals.

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