Specbee: How to Integrate Google Tag Manager with Drupal 8 – An easy step-by-step tutorial

How to Integrate Google Tag Manager with Drupal 8 – An easy step-by-step tutorial
Shefali And Shruthi
05 Jan, 2021

Marketers are constantly on the lookout for ways to boost website engagement and increase interactivity.   Various third-party integrations and tracking tools are tried and tested to see what works best for the business. But over time, keeping a track of all these snippets/tags/integrations that are hardcoded on the website can get tedious and messy. And that’s where Google Tag Manager comes in. In this article, you will learn about how to integrate Google Tag Manager with your Drupal 8 website.
Integrating Google Tag Manager with Drupal 8

What is Google Tag Manager and how can it help?

Google Tag Manager is like a toolkit. It has all the tools you need meticulously organized in one place. Tools like Google Analytics, Adwords, personalization tools, A/B testing tools, Remarketing, Native advertising pixels, and much more. All the integration tags can be stored in Google Tag Manager for better access and management. How can it help, you ask?

  • Marketers find it greatly beneficial as they don’t have to depend on developers to add and modify integration tags on the website. They can easily do it themselves.
  • Better organization of tags can help marketers’ access and manage their integrations easily.
  • Updating tags don’t require you to change them on multiple web-pages. 
  • Test if your tags get triggered on any event/action in the preview mode.
  • You can even check for formatting or security issues before deploying it to live.
  • Provides an extra layer of data security.

Integrating Google Tag Manager in Drupal 8

Drupal 8 integrates seamlessly with Google Tag Manager and installing it is also a breeze. This module is also compatible with Drupal 9! Now that we know how useful Google Tag Manager is, let’s move on to integrating it with your Drupal 8 website.

STEP 1 – Install the module

You can download the Google tag Manager module here.

Or run this command through composer with this command :

composer require 'drupal/google_tag:^1.4'

Install the GTM module

STEP 2 – Configure the Module

In the admin toolbar, go to Configuration-> System -> Google Tag Manager
Configure the GTM module

STEP 3 – Open Container Page

Once you click on Google Tag Manager, you will see a container page like this –
Open container page

STEP 4 – Add a Container

Click on the Add container button. This is where you will add the Container ID that you had created previously when you signed up with GTM. If not done already, go here to signup and create a container ID for yourself (shown in the below steps).
Add a container

STEP 5 – Create a Container

Under Account setup, give the Account name and your Country name.

Under Container setup, give the Container name and select the target platform as per your requirements.

Click on the Create button.
Google Tag Manager-Create n account

Step 6 – Get the Container ID

Once done, you will be able to see a popup screen that will display the code snippet that needs to be pasted in the head section. Look out for the Container Id which will look like an alphanumeric word and begins with “GTM”. Here it is “GTM-MXQN9XL”. Copy this code to your clipboard.
Tag Manager Code - get the container ID

Step 7 – Insert the Container ID

Head back to your Drupal setup where you had to add the container ID. Give a name for your container in the Label field and paste the previously copied container ID in the Container ID field. Save the configuration.
Insert container ID

Step 8 – And we’re all set!

To verify if the installation of Google tag manager has been successful in your Drupal site, go to the home page of your website and do an “Inspect Element”. If it has been installed properly, you should be able to see it within the

Check if GTM module is properly installed

Shefali ShettyApr 05, 2017