# Google Tag Manager (GTM) - Consent Mode

Commanders Act provides a tag template to manage the "[Consent Mode](https://developers.google.com/tag-platform/devguides/consent)" in Google Tag Manager.\
This seamless integration takes advantage of our Commanders Act OnSite API.

{% hint style="info" %}
Please note: Google only requires a validated consent signal only for EEA countries and UK.

Implementing Google Consent Mode in regions beyond may negatively impact campaign performance and is not recommended.
{% endhint %}

## Setup

Depending on your needs, the following summarizes all recommended steps:

1. Access [GTM](https://tagmanager.google.com/).
2. Select your "Web" type container.
3. Add our [tag template](https://tagmanager.google.com/gallery/#/owners/TagCommander/templates/GTM-OnSite-API) from the Google "Community Template Gallery".
4. [Configure the related tag and its trigger](#configure-the-related-tag-and-its-trigger).
5. [Configure your third-party vendor tags](#configure-your-third-party-vendor-tags).
6. [Enable TCF Support for gtag](#enable-tcf-support-for-gtag).
7. [Manage multiple privacies](#manage-multiple-privacies).
8. Test and [publish your container](https://support.google.com/tagmanager/answer/6107163?hl=en).

## Configure the related tag and its trigger

Following the above steps, adding our template "[**Commanders Act CMP**](https://tagmanager.google.com/gallery/#/owners/TagCommander/templates/GTM-OnSite-API)" from the Google "Community Template Gallery", you're presented with the following "**Tag Configuration**" which is the core area where you can manage your consent needs with GTM:

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-ff17b0d499ef4c6f5895816e0e5f80a83f3dd882%2Fonsite_api1.png?alt=media" alt=""><figcaption><p>The "Commanders Act CMP" configuration in GTM.</p></figcaption></figure>

First, you need to input your consent category identifiers for the following **7 categories**: `Ad Storage`, `Analytics Storage`, `Functionality Storage`, `Personalization Storage`, `Security Storage`, `Ad User Data` and `Ad Personalization`. You can define/find these identifiers by logging in to our platform and follow the section:\
`(A)`"**Data Governance**" → `(1)`"**Consent Management**" → `(2)`"**Categories**".

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-cc8990f63e27beb20f8184c24a77834ea276125e%2Fonsite_api2.png?alt=media" alt=""><figcaption><p>Define/find your category identifiers.</p></figcaption></figure>

Your identifiers are shown between round parentheses (see highlighted in green below):\\

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-9ca50746a2393fa8c82249c6a4245d0a4e9c0b2d%2Fimage.png?alt=media" alt="" width="518"><figcaption></figcaption></figure>

{% hint style="info" %}
If you have sub-categories with the same scope of the five defined by Google, you need to use their ids instead of the main category ones. You can also rename your categories or change their ids by checking the subsection "[**Managing categories**](https://community.commandersact.com/trustcommander/user-guides/categories-and-tags/manage-categories#managing-categories)".
{% endhint %}

If your CMP loads asynchronously, it might not always run before your GTM container. That’s why you have the option to set a "**Wait for update**" value in milliseconds to control how long to wait before data is sent. This field is optional and its default value is 0. In case you need to set it, we recommend starting from the base value of 500 milliseconds.

You also need to set the default status, for each of the 7 categories, before users interact with your [**privacy banner**](https://community.commandersact.com/trustcommander/user-guides/privacy-banners) and taking into account region-specific behavior. This is done by clicking the "Add Row" button and selecting either "Denied" or "Granted" to match with your input regions and/or sub-regions.

{% hint style="info" %}
Ensure that your default command accounts for regional variations in your consent strategy. For more information on customizing the default command, you can see Google’s documentation [here](https://developers.google.com/tag-platform/devguides/consent#region-specific_behavior).
{% endhint %}

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-37daacdfd88918277fff011c6310e30f97f85e3d%2Fonsite_api4.png?alt=media" alt=""><figcaption><p>Select your default status for each category and by region and sub-region.</p></figcaption></figure>

To make sure that the consent is correctly managed by GTM with third-party vendor tags, we strongly recommend to enable reactive events. Turn on the `(3)` "**Advanced Features**", `(4)` "**Activate Reactive Events**" and `(5)` "**Activate \[Storage-Name] Reactive Event**" for each \[Storage Name] you're using. Finally, enter their `(6)` "**Event Name**". These events will be used in the next section when configuring your third-party vendor tags.

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-460b04a4f2a90cacc94756fa00b5ca7b8524d92d%2Fonsite_api5.png?alt=media" alt=""><figcaption><p>Reactive events activation under "Advanced Features".</p></figcaption></figure>

You also have the option to directly inject your CMP script by turning on the `(7)` "**Advanced Features**", `(8)` "**Inject CMP Script**" and input your `(9)` "**URL**".

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-b4cdef603eec7e6094bcfd37ae2156bbd3b9ed64%2Fonsite_api6.png?alt=media" alt=""><figcaption><p>Inject your script directly using this template.</p></figcaption></figure>

Disabling the default consent may come handy when you don't want to use the Consent Mode.\
This is done by turning on the `(10)` "**Advanced Features**" and `(11)` "**Disable Default Consent**".

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-2f4c8294c7c569346a7cf626c7e0680aba03822f%2Fonsite_api7.png?alt=media" alt=""><figcaption><p>Disable the "Default Consent".</p></figcaption></figure>

As the last step, you need to select the "Consent Initialization - All Pages" trigger in the "**Triggering**" lower area:

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-64e8cf2004f7ee9c382a640adacf732d1715a57e%2Fimage.png?alt=media" alt=""><figcaption><p>Select "Consent Initialization - All Pages" as trigger.</p></figcaption></figure>

#### Modify Permissions

If your banner is hosted on your servers (on premise) or if you use our [CDN 1st party feature](https://doc.commandersact.com/configure/administration/domain-management), then you need to update the Permissions of the template.

Simply add your host URL in the tab "Injects scripts" (see block "allowed patterns").

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-e7c689b7fb3307b0d43ca6ee63d8e72330bfd3fe%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

## Configure your third-party vendor tags

Third-party vendor tags require additional settings to properly operate with the user consent. First, open your tag configuration and check under the `(12)` "**Advanced Settings**" and `(13)`"**Consent Settings**" if a consent type (E.g. "*ad\_storage*") is already preconfigured, if not you need to add it by selecting the option `(14)` "**Require additional consent for tag to fire**" and `(15)` input the consent type(s) you want to include.

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-a3562039504e94c2c66027c1eb30b31ab6989a7e%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

Then, you need to configure its triggers and this is where we're going to use our reactive events we prepared in the previous section. Locate the "**Triggering**" area in your tag configuration and add a "[**Trigger Group**](https://support.google.com/tagmanager/answer/9164222?hl=en)".

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-dbdb48c1dbd761389eedcb1ecba9b9bda8d94f43%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

In the trigger group add `(16)` any preexisting triggers and `(17)`a trigger named as your configured reactive event.

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-4c6d2495962199b16b2800d31eb8117078e0e21b%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

The latter has to be configured as a `(18)`"**Custom Event**" with the same `(19)`"**Event Name**" you used in the previous section and it has to fire on `(20)`"**All Custom Events**".

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-705be3518f07e7aadfcbdcd4d5095934ac71ca53%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

This completes your configuration. You can now start the testing phase, leading to the final deployment in production. Learn more on how you can configure and run tests with your tags in GTM by checking the section "[**Consent configuration**](https://support.google.com/tagmanager/answer/10718549/?hl=en-GB)" in the "[**Help Center**](https://support.google.com/tagmanager/)". You can also read the page [Consent Mode setup](https://developers.google.com/tag-platform/security/guides/consent) provided by Google for Developers

{% hint style="info" %}
Look our ["Test your configuration"](https://doc.commandersact.com/features/consent-management/setup-guides/tag-manager/google-consent-mode-in-commanders-act-tms#test-your-configuration) page for debbuging hints!
{% endhint %}

{% hint style="warning" %}
Regarding the configuration of your workspace on the Commanders Act platform, there is no need to activate anything special for Consent Mode. Everything is managed via Google Tag Manager.\
However, you must add the following URL to the privacy centre of your CMP:\
<https://business.safety.google/privacy/>\
**This is a legal requirement.**
{% endhint %}

## Enable TCF Support for gtag

{% hint style="info" %}
Check [Google Ads integration with the IAB Transparency & Consent Framework (TCF)](https://support.google.com/google-ads/answer/10021549?hl=en) for more details on how you can set up the IAB Transparency and TCF Framework.
{% endhint %}

You can enable TCF support with your Google Ads tags under `(21)` "**Advanced Features**" by flagging `(22)` "**Enable TCF Support for gtag**".

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-a5edc3377af4ae62439869f3016d90fc3ba977e0%2Fconsent_21_22.png?alt=media" alt=""><figcaption></figcaption></figure>

### Validate TCF settings

You can use the [IAB Europe official Chrome extension](https://chromewebstore.google.com/detail/cmp-validator/ffhhjklgcfabkpholngojpkijlafjooc?authuser=1\&pageId=none) to check webpages for a TCF registered CMP and see if vendors are properly configured matching the user consent.\
It's recommended to inspect the `(23)` "**Vendors (Consent)**" by `(24)` expanding the section:

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-49c8bb398bbc431f07c243cc5c74bfbccf464785%2Fconsent_23_24.png?alt=media" alt=""><figcaption></figcaption></figure>

Look for the vendor name, and ensure it's reported with the proper consent status. In the following example, `(25)` "**Google Advertising Products**" is correctly green flagged as the user granted their consent:

<div data-full-width="false"><figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-c01c99046c0c3ad7c41936b5e5f811227eb078d1%2Fconsent_25.png?alt=media" alt=""><figcaption></figcaption></figure></div>

## Manage multiple privacies

As detailed in the [Configure the related tags and its trigger](#configure-the-related-tag-and-its-trigger), you have the option to inject your CMP script:

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-8392b482c6052109abc328a117a708076e1dd798%2Fconsent_26_27.png?alt=media" alt=""><figcaption></figcaption></figure>

This allows you to set your `(26)` **script URL**, in a dedicate field, but how can you manage multiple privacy scripts, for example, based on the language ? You can use a GTM variable to define the logic you need. Click the `(27)` **the icon** on the right of the URL field and, in the top right corner, click the `(28)` **plus sign**:

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-ae1109dc698e937e334ecaf6ecd6865cc52d60d2%2Fconsent_28.png?alt=media" alt=""><figcaption></figcaption></figure>

This will bring up a new window where you can create a new variable.\
In the following example, we will use a "Lookup Table" variable that holds the URL based on another variable named "Browser Language".\
FIrst, give a `(29)` **name** to your variable and, in the `(30)` "**Lookup Table**" section, configure our wanted logic. In the "Output" column, ensure that "url EN banner" and "url FR banner" are replaced with the actual full URLs:

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-7e7952826406ececa68c5b512c046a6fb226d95f%2Fconsent_29_30.png?alt=media" alt=""><figcaption></figcaption></figure>

After saving the variable, it will be set in the URL field:

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-46fca05e50701a6df00d921b59ef4e1255b9118e%2Fconsent_A.png?alt=media" alt=""><figcaption></figcaption></figure>

Finally, save your tag and [publish your changes](https://support.google.com/tagmanager/answer/6107163?hl=en).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.commandersact.com/features/consent-management/setup-guides/tag-manager/google-tag-manager-gtm-consent-mode.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
