Support Google Consent Mode v2 through Google Tag Manager with consent.studio
After completing the following steps, you will have a Google Tag Manager container set-up with Consent Overview enabled and have the consent.studio CMP installed with basic settings.
First things first: you need to have set-up a Google Tag Manager container and installed it on your website. This article from the official Google documentation will help you do this.
Good to know: For WordPress websites, Google has the Google Site Kit plugin available that helps you to easily install Google Tag Manager on your WordPress website — without the need to code.
The Consent Overview page provides a high level view of all the consent settings across the tags in your container and helps you adjust them for individual tags.
Consent Overview is not enabled by default on your Google Tag Manager container. Enable it using these instructions from the official Google documentation.
Log in at https://consent.studio. If you do not yet have an account, you can create one here.
After having registered your site for our free trial, you will find that the configuration of your site is order in a specific flow of steps. These are navigable from every main configuration component in your dashboard, using the buttons with the arrow icons.
Open the Cookie Banner page under Settings and scroll to the Installation section
Add our Google Tag Manager tag template (consent.studio CMP
) from the Template Gallery to the GTM container that is active on the domain that you have registered with consent.studio.
When you have added the template to the relevant GTM container, open the Tags tab, click New and add consent.studio to the Tag Manager container. The trigger must be Consent Initialization - All Pages.
Google Consent Mode v2 is best supported when installing our tag for Google Tag Manager. For this to work properly, please use the “Consent Initialization - All Pages” trigger for the official Google Tag Manager tag.
Implementing Consent Mode v2 can be divided in two approaches:
With the basic approach, you will block specific tags until a consent update allows them to load. You can achieve this with the cookie_consent_update
event (or one of our specific events) that ships with consent.studio.
With the advanced approach, you will load them nevertheless. However, the tags will adapt to the actual consent states and change their behavior accordingly. You can then use the All Pages
trigger that is available in Google Tag Manager.
As the basic approach of consent mode entails that tags are not loaded at all until consent has been provided for a specific category, we will leverage the built in dataLayer events of consent.studio to achieve this.
cookie_consent_granted_functional
;cookie_consent_granted_analytics
.cookie_consent_granted_marketing
.
To create a new custom event trigger (cited from Google's documentation):
Implementing advanced consent mode is, ironically, simpler, as you will load tags as you normally should — based on the trigger that best suits your use case. This could be the All Pages trigger, for instance.
Note that not every tag that you install in your Tag Manager container may respect the consent signals provided by consent.studio through Google Consent Mode. If you are unsure, it might be best to use basic consent mode for these tags and not load them at all until consent has been provided by the visitor for the specific tag.