Set up Google Analytics
Tracking visitor activity on your website shows you what works and what can improve. This page connects your Drupal CMS site to Google Analytics with the Google Analytics recommended add-on, either directly or through Google Tag Manager.
Google Analytics collecting data from your site, with the tag added by the recommended add-on instead of site code.
Prerequisites
Section titled “Prerequisites”- A running Drupal CMS site and an administrator account.
- A Google Account.
- What tags and containers are; see Tags and analytics.
Create a Google Analytics property
Section titled “Create a Google Analytics property”Create a Google Analytics property for your website with Web as the platform, and note its Measurement ID (it looks like G-XXXXXXXXXX). Name the property for the site and environment, for example Oregon Wine Tours - Live. Follow Google’s Set up Analytics for a website and/or app (support.google.com).
Choose how the tag reaches your site
Section titled “Choose how the tag reaches your site”The add-on accepts any Google tag ID, so pick one path:
- Google Analytics only: use the Measurement ID from the previous step. Drupal CMS loads Google Analytics directly, and there is nothing more to set up in Google.
- Google Tag Manager: create a Tag Manager container for your website, and use its Container ID (it looks like
GTM-XXXXXXX). You then manage Google Analytics and any other tags in Tag Manager instead of on the site. Follow Google’s Set up Google Analytics in Tag Manager (support.google.com) to create the container, add a Google tag with your Measurement ID, and publish the container.
Add your ID to Drupal CMS
Section titled “Add your ID to Drupal CMS”- Sign in to your Drupal CMS site as an administrator.
- Go to Extend → Recommended
/admin/modules/browse/recommendedand select Install for Google Analytics. - At the prompt, paste your Measurement ID or Container ID into the Google Tag ID field.
- Remove any extra spaces from the beginning or end of the pasted ID. Spaces can prevent tags from loading properly.
- Select Continue.
The default tag settings at Configuration → Web services → Google Tag/admin/config/services/google-tag now carry your ID, and Drupal CMS adds the tag code to every page of your website.
Verify
Section titled “Verify”- Visit your website in a new window.
- When the privacy consent window appears, select Customize, then toggle on all categories so the Google Analytics tracking cookies are included.
- Use the Tag Assistant Chrome extension, or the Realtime report in Google Analytics, to confirm your tag is firing. With Tag Manager, Preview in Tag Manager shows the same.
If your tags are not firing:
- Check for extra spaces at the beginning or end of your Google Tag ID. Verify or update the value at Configuration → Web services → Google Tag.
- With Tag Manager, confirm that your container is published. Each change in Tag Manager creates a version, and nothing applies to your site until you publish the version.
- Review the privacy consent banner settings: analytics tags may be blocked until consent is given. The banner is controlled by the Klaro module at Configuration → User interface → Klaro! settings
/admin/config/user-interface/klaro. The consent cookie is namedklaro; delete the cookie and refresh a page on your site to re-trigger the consent prompt.
Related
Section titled “Related”- Tags and analytics explains the concepts this setup relies on.
- Submit your site to search engines covers the checklist items these accounts complete.
- Google’s guides: Set up Google Analytics in Tag Manager and Set up Analytics for a website and/or app (support.google.com).
Was this page helpful?
Drupal is a registered trademark of Dries Buytaert.