Like all other websites, Drupal websites require marketing for retaining and increasing their share of audience and revenue.
Google Tag Manager for Drupal is an excellent tool for adding and updating tags to your website without editing code of your website. The best thing about the tool is that it is free to use for all users.
Implementing Google Tag Manager in Drupal 7 was pretty straightforward thanks to a custom module. The same idea is carried into Drupal 8, although the custom module is not available on the official Drupal module directory. However, the module is available at the GitHub.
The process of integrating Google Tag Manager in Drupal websites comprises of:
- Install Module on the Drupal website.
- Create an account for Google Tag Manager.
- Copy the container ID.
- Configure the module.
- Verify whether GTM is present at the website.
- Implement the Google Analytics script through Google Tag Manager.
Install the Module on Your Drupal Website
First of all, download the google_tag module from GitHub. Now login to your Drupal website as the admin, navigate to the Extend tab and click Install new module button. Next, upload the module’s zip file you downloaded earlier.
After the installation is complete, enable the module.
Create an Account in Google Tag Manager
Go to Google Tag Manager and use your Google account to login. After logging in, click Create Account. Give the account the name of your website and continue. You will now be required to give a container name. Enter a relevant name or the name of your website and click Create.
Copy the Container ID
After clicking Create on the previous screen, a splash screen with code snippets will appear. Copy the container ID from this screen.
Configuration of the google_tag Module
I will now go back to the Drupal website. Once there, click the Configuration tab and navigate to Google Tag Manager. On the very first screen, paste the container ID (copied earlier) into the field titled Container ID. Next, click Save configuration.
Verify GTM Code on Your Website
The simplest way to check whether the Google Tag Manager is properly implemented on your website is by using the inspect element option. Just go to your website’s homepage, right click and select inspect element from the context menu. In the screen that opens, search for “Google Tag Manager”. If you have successfully implemented Google Tag Manager, you should see a script like the one in the screenshot below.
Implement Google Analytics Through Google Tag Manager
As a website admin, you could use Google Tag Manager to implement various scripts very easily. To demonstrate this functionality, I will demonstrate how to install Google Analytics using GTM.
Go to your Google Tag Manager account, and navigate to the following directory: Tags > New > Name your Tag > Tag Configuration > Select Universal Analytics.
Next, go to the Google Analytics account and copy the Tracking ID.
Now simply paste the Google Analytics Tracking ID into the Google Tag Manager’s Tag configuration and click Save.
That’s it! You’ve successfully implemented Google Analytics through GTM into your Drupal website.
Nothing as Easy as Deploying Drupal Apps on Cloud
With Cloudways, you can have your Drupal apps up and running on managed cloud servers in just a few minutes.
Conclusion
Google Tag Manager is yet another example of how modules make everything so simple in Drupal. As you have seen in this tutorial, implementing Google Tag Manager in Drupal website is really easy! If you found this blog post useful you might like to check out another post by us on: Speed Up Drupal Websites With Google AMP. If you wish to contribute to the discussion, do leave a comment below!
Create interactive Drupal websites easily on the Cloud.
Host your website on optimized Drupal hosting servers.Hamza Zia
Hamza is a Drupal Community Manager at Cloudways - A Managed Drupal Hosting Platform. He loves to write about Drupal and related topics. During his free time, he can be seen obsessing over Football, Cars, Android and Gaming.