Consent Mode in Google Tag Manager (outdated)

This article is outdated and showing legacy way of implementing CookieHub to Google Tag Manager.

Please use our latest instructions instead to avoid issues:

Google Tag Manager Implementation


Consent mode (beta) allows you to adjust how your Google tags behave based on the consent status of your users. You can indicate whether consent has been granted for Analytics and Ads cookies. Google's tags will dynamically adapt, only utilizing measurement tools for the specified purposes when consent has been given by the user.

Products that support consent mode include:

  • Google Ads*
  • Floodlight
  • Google Analytics

* includes Google Ads Conversion Tracking and Remarketing; support for Phone Call Conversions pending

You can find further information about Consent mode here.

Sections

CookieHub and Consent mode

CookieHub has built-in support for Consent mode for Google Tag Manager and no changes are required to enabling it when using the CookieHub GTM template. When using Consent mode, you should not use the CookieHub GTM recipe as you will use normal GTM triggers for your tags.

Supported consent types

Consent mode type Linked CookieHub category
security_storage Necessary
functionality_storage Preferences
personalization_storage  Preferences
analytics_storage Analytics
ad_storage Marketing

How to setup CookieHub in Google Tag Manager with Consent mode

Please note that the CookieHub template for Google Tag Manager is currently pending review and approval. Once approved, you will be able to locate the CookieHub template in the Community Template Gallery but until then, an additional step is required to import the template in GTM.

CookieHub GTM template repository on Github

Install the CookieHub template

1. Download  the CookieHub template here  or from the offical CookieHub repository on Github

2. Log into Google Tag Manager, select your Tag manager container and click the Templates link in the left menu.

3. Click the New button in the Tag Templates section.

4. Click the three dots in the top right corner and select Import.

5. Select the template.tpl file previously downloaded. The template will now be imported and you should see the name, description and other fields populate.

6. Click the Save button in the top right corner and close the Template Editor.

Create the CookieHub tag

You will have to create a CookieHub tag in your Google Tag Manager container to load the CookieHub widget. This tag uses the previously imported CookieHub template.

1. Log into Google Tag Manager, select your Tag manager container and click the  Tags link in the left menu.

2. Click the New button in the Tags section:

3. Click the Tag Configuration section, scroll down to the Custom tag types and click the CookieHub tag:

4. Type your 8 character CookieHub domain code (you can find the code in the Overview tab for your domain in the CookieHub dashboard) and check the Enable Consent Mode checkbox:

Optionally you can change the default consent state for each consent type. By default, only the security_storage consent type is granted.

5. Select Consent Initialization - All Pages as the Firing Trigger and save the tag.

If all tags in your Google Tag Manager container support Consent mode, you don't have to do anything more and can go ahead and publish the changes. If you have other tags that need to be conditionally loaded based on consent state, follow the next section to create the additional consent state updated trigger.

Create consent updated trigger

When tags don't have built-in Google Consent mode support you can use the Additional Consent Checks as described in the next section but we will need an additional trigger in Google Tag Manager to trigger these tags so that they trigger after CookieHub has set the correct initial consent state or when the user changes his cookie consent using the CookieHub dialogs.

1. Log into Google Tag Manager, select your Tag manager container and click the  Triggers link in the left menu.

2. Click the  New button in the Triggers section:

3. Click the  Trigger Configuration section and select the Custom Event trigger type:

4. Type  cookiehub_consent_update in the Event name field and leave everything else unchanged:

5. Save the trigger and set the name to something descriptive like  CookieHub - Consent Update


Using Additional Consent Checks for tags that don't have built-in Google Consent mode support

Please note that only a few tags have built-in Google Consent mode support. For other tags, we'll have to use the Additional Consent Checks feature in Google Tag Manager that can be used with any tags. In this example, we're using the Facebook Pixel tag type.

1. Log into Google Tag Manager, select your Tag manager container and click the   Tags link in the left menu.

2. Click the tag that you want to modify:

3. Click the  Tag Configuration section, scroll down and expand Advanced Settings

4. Expand  Consent Settings and click the Require additional consent for tag to fire radio box.

5. Click the  Add required consent button and select the consent type that you want to use with this tag:

6. Change the Firing Trigger for this tag to  CookieHub - Consent Update:

7. Save and publish the Tag Manager container and you're all set. Repeat these steps for all tags that don't have built-in Consent Mode support. 

Page view / All Pages triggers for tags that don't have built-in consent mode support

You can trigger tags that don't have built-in Google Consent mode support by creating the consent updated trigger and using the additional consent checks as described in the previous sections but in some cases you may need to use page view triggers instead of custom triggers.

Using page view triggers and additional consent checks is fully supported by the CookieHub GTM template but since the page view triggers have already been fired when the user consents the first time or changes his consent at a later time, the tag won't fire for that page view and you may miss out on analytical data. To make sure the tag is fired for every page, you'll need to add the Choice modified trigger which is fired when the user allows or denies all cookies and when consent settings are updated from the settings dialog.

Follow these steps to create the Consent Modified trigger:

1. Log into Google Tag Manager, select your Tag manager container and click the  Triggers link in the left menu.

2. Click the   New button in the Triggers section:

3. Click the   Trigger Configuration section and select the Custom Event trigger type:

4. Type   cookiehub_modified in the Event name field and leave everything else unchanged:

5. Save the trigger and set the name to something descriptive like   CookieHub - Choice Modified

You can now update the firing triggers for tags requiring additional consent so that they are fired either for All pages or when users update the cookie choices. Here's an example:

Update template

Occasionally, we add features and deploy fixes to the CookieHub GTM template. Follow these steps to update the template if you are missing any features or have been instructed to update it.

1. Download the CookieHub template here  or from the offical CookieHub repository on Github

2. Log into Google Tag Manager, select your Tag manager container and click the Templates link in the left menu.

3. Click the CookieHub template and from the  three dots in the top right corner, select Import

4. Select the template.tpl file previously downloaded and click Continue to override the current template.

5. Click the Save button in the top right corner and close the Template Editor.

Still need help? Contact Us Contact Us