Tracking visitor activity on your website helps you understand what’s working and what can be improved. With Drupal CMS, you can easily connect your site to Google Analytics using Google Tag Manager by installing the Google Analytics recommended add-on.
By the end of this tutorial, you will be able to:
- Set up Google Analytics and Google Tag Manager accounts.
- Add your Google Tag Manager Container ID to your Drupal CMS site.
- Configure Google Analytics tags in Google Tag Manager.
- Verify that your website is being tracked successfully.
Goal
Set up Google Tag Manager and Google Analytics in Drupal CMS to start collecting visitor insights and tracking site activity.
Back to topPrerequisites
- Introduction to tags and analytics in Drupal CMS
- A Google Account (Gmail or Workspaces – create one if needed)
- Administrator access to your Drupal CMS site.
Why Use Google Tag Manager?
Google Tag Manager lets you manage all your tracking tags — including Google Analytics — from one central place. You can add, update, and organize tags without editing your website's code. This makes it easy for marketers, editors, and site owners to run experiments, add marketing pixels, or change analytics settings without needing help from a developer.
Drupal CMS helps by providing the Google Analytics recommended add on (Extend > Recommend > Google Analytics) which installs and configures the Google Tag module. The Google Tag module adds your Google Tag Manager container to every page on your site. Once that’s done, you can manage your tags directly in Google Tag Manager, and they will run automatically on your site.
Let’s walk through the process of how to set up Google Analytics in Drupal CMS.
Back to topStep 1: Create a Google Analytics Property
- Visit Google Analytics and sign in.
- Click Admin (bottom of left toolbar) and create a new Property for your website. If the Property link is not available, select Account and after creating an account, you’ll be prompted to create a new property. Name your property specific to the site and environment; for example, “My Drupal CMS Site - Local” or “Oregon Wine Tours - Live”.
- Follow the prompts and select Web as your platform.
- Note your Measurement ID — you’ll need this later.
For detailed instructions, see [GA4] Set up Analytics for a website and/or app (support.google.com).
Back to topStep 2: Create a Google Tag Manager Account and Container
- Visit Google Tag Manager and sign in.
- Create a new account if needed.
- Create a Container for your website and choose Web as the target platform.
- Copy the Container ID (looks like GTM-XXXXXXX).
For detailed instructions, see Set up Google Analytics in Tag Manager (support.google.com).
Back to topStep 3: Add Your Container ID to Drupal CMS
- Sign in to your Drupal CMS site as an administrator.
- Go to Extend > Recommended > Google Analytics and press Install.
- At the prompt, paste your Container ID from Google Tag Manager into the Google Tag ID field (looks like GTM-XXXXXXX).
- Important: Remove any extra spaces from the beginning or ending of the ID after you paste it into the Google Tag ID field. Spaces can prevent tags from loading properly.
- Click Continue.
- The Default Tag Settings at Configuration > Web Services > Google Tag (admin/config/services/google-tag) are now configured with your Google Tag Manager container ID.
Drupal CMS will now automatically add the GTM code to your website.
Back to topStep 4: Add a Google Analytics Tag in Google Tag Manager
- Open your container in Google Tag Manager.
- Click Tags, then New.
- Choose Google Analytics: GA4 Configuration as the tag type.
- Enter your Measurement ID from Step 1.
- Set Triggering to All Pages.
- Click Save.
- Click Submit and Publish your container.
Step 5: Verify Tracking
- Visit your website in a new window.
- Use the Tag Assistant Chrome extension or click Preview in Google Tag Manager to verify your tag is firing.
- When the privacy consent window appears, click Customize, then toggle on all categories to include Google Analytics tracking cookies.
Troubleshooting tips
If your tags aren’t firing:
- Check for extra spaces at the beginning or ending of your Google Tag ID. Go to Default Tag Settings at Configuration > Web Services > Google Tag (admin/config/services/google-tag) to verify or update the value.
- Confirm that your tag in Google Tag Manager is published. Each time you make a change in Google Tag Manager a version is created. You must publish the version before your changes will be applied.
- Review privacy consent banner settings — analytics tags may be blocked until consent is given. The privacy consent banner is controlled by the Klaro module. Its settings may be found at Configuration > User interface > Klaro! settings (admin/config/user-interface/klaro). The cookie is named klaro. Delete the cookie and refresh a page on your site to re-trigger the privacy consent prompt.
- Use Preview mode in Google Tag Manager or the Chrome extension, Tag Assistant (Google), to verify the tags are loading.
Wrap-up
In this tutorial, you learned how to:
- Set up Google Analytics and Google Tag Manager.
- Add your GTM Container ID to Drupal CMS.
- Create a Google Analytics tag in Google Tag Manager.
- Verify that your tracking is working.
With analytics in place, you can start learning more about your visitors and improving your site.
Back to topAdditional resources
- Set up Google Analytics in Tag Manager (support.google.com)
- Set up Analytics for a website and/or app (support.google.com)