Skip to content

Cookiebot + GTM

Integrates Cookiebot consent management with Google Tag Manager to ensure GDPR compliance by preventing cookies and scripts from running before user consent.

For a full description of the module, visit the project page.

To submit bug reports and feature suggestions, or track changes: issue queue.

Table of contents

  • Requirements
  • Installation
  • Configuration
  • Helpful links

Requirements

This module requires the following:

  • A Cookiebot account with Domain Group ID (CBID)
  • A Google Tag Manager account with Container ID (GTM-XXXXXXXX)

Installation

Install as you would normally install a contributed Drupal module. Visit Installing Drupal Modules for further information.

Configuration

Navigate to Administration » Configuration » Cookiebot + GTM (/admin/config/cookiebot_gtm) to configure the module. The settings are organized into three sections:

Cookiebot Settings

Configure your Cookiebot consent management:

Cookiebot domain group ID (CBID): Your unique Cookiebot ID (format: 00000000-0000-0000-0000-000000000000). This can be found in the Cookiebot Manager on the "Your scripts" tab for your domain. Or if you login on https://admin.cookiebot.com/, under "Implementation".

Cookie-blocking mode: - Auto: Uses Cookiebot script for automatic cookie blocking - Manual: Without script for custom implementations

Use multilingual Cookiebot: Enable language-specific consent banners based on the current language.

Google Tag Manager Settings

Configure your Google Tag Manager integration:

Google Tag Manager container ID: Your container ID (format: GTM-XXXXXXXX). This can be found at the top of your container page in Google Tag Manager next to the container name.

Use different Google Tag Manager ID per language: Enable separate Google Tag Manager containers for each language. When enabled, you can specify container IDs for each language.

Google Tag Manager hostname: Only needed for server-side tagging. Leave empty to load GTM from the default https://www.googletagmanager.com. With server-side tagging, enter the URL of your tagging server; it is set up in a separate Server container in Google Tag Manager, not in the Web container whose ID you entered above. See Server-side tagging.

Google Tag Manager environment ID and token: Only needed to load a non-live GTM environment, for example on a staging site. In Google Tag Manager go to Admin » Environments, open the environment and use Actions » Get snippet (or Share preview). The environment ID is the gtm_preview value (like env-2), the token is the gtm_auth value. Fill in both, or leave both empty for production. See Environments.

Google Consent Mode tells Google tags (such as Google Analytics and Google Ads) what the visitor has consented to. Without consent they set no cookies and only send cookieless signals. See Set up consent mode.

Enable Google Consent Mode: Adds a "consent default" to the page before GTM loads. When the visitor makes a choice in the Cookiebot banner, Cookiebot updates the consent.

The consent types below set that default: what Google tags may do before the visitor has made a choice. A checked type is granted, an unchecked type is denied. In the EU, leave them unchecked unless you are sure consent is not required. - Ad personalization: Personalized advertising - Ad storage: Cookies for advertising - Ad user data: Sending user data to Google for advertising - Analytics storage: Cookies for analytics, such as visit duration - Functionality storage: Cookies for website functionality, such as language - Personalization storage: Cookies for personalization, such as recommendations

The cookie declaration page is automatically available at: /cookie-declaration

The declaration is filled after Cookiebot has scanned your site, which requires a publicly reachable URL.