Advanced Consent Mode - Implementation instructions
The instructions below are to implement Advanced consent mode when using Google Tag Manager to deliver Google Services such as Google Analytics 4, Google Ads, Conversion Linker, and more.
⚠️ Note: Usercentrics is a Certified CMP Partner of Google. Regardless of which Certified CMP you use, these steps (or very similar steps) will need to be taken for your website to be compatible with Google's Consent Mode V2.
Prerequisites
The overall approach to updating your consent tool to be compatible with consent mode V2 is similar in nature for all Google certified CMP partners. In this example, we will show how to make these updates using Termageddon (and its 3rd party partner Usercentrics CMP).
The prerequisites for setting up GTM V2 compatibility are:
A Termageddon license, with an activated Cookie Policy and consent tool.
A Google Tag Manager account, with the regular GTM script added to the <head> of your website.
Please note this is documentation to set up compatibility with Google’s Advanced Consent Mode V2. If you are looking for Basc Consent Mode instructions (which is considered a better practice from a privacy perspective), please review these steps instead. This documentation is not how to set up with the TCF framework. Google's Basic Consent Mode Version 2 (v2) - Instructions : Termageddon
Step #1 - Update your Google Tag Manager Script to V2
The first step is to update the Google Tag Manager script within your website to the Consent Mode V2 script provided by Google.
The original script will look something like this:
<script> (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,’script','dataLayer','GTM-XXXXXX');</script>
You need to replace this script with the updated GTM Consent Mode V2 script:
<script type="text/javascript"> // create dataLayer window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } // set „denied" as default for both ad and analytics storage, as well as ad_user_data and ad_personalization, gtag("consent", "default", { ad_user_data: "denied", ad_personalization: "denied", ad_storage: "denied", analytics_storage: "denied", wait_for_update: 2000 // milliseconds to wait for update }); // Enable ads data redaction by default [optional] gtag("set", "ads_data_redaction", true); </script> <script type="text/javascript"> // Google Tag Manager (function(w, d, s, l, i) { w[l] = w[l] || []; w[l].push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' }); var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f); })(window, document, 'script', 'dataLayer', 'GTM-XXXXX'); //replace GTM-XXXXXX with Google Tag Manager ID </script>
Be sure to update “'GTM-XXXXX'” to your respective GTM ID in the above code.
Step #2 - Add the Usercentrics Tag Template to your GTM account
For a google certified consent tool to properly respond to user consent settings, you will need to add a CMP tag template to your Google Tag Manager account. For our example, we will add the Usercentrics tag template.
Log into Google Tag Manager account and select the respective account (website or app) that you will be performing this update for.
Click Templates on the left hand side
For “Tag Templates”, click “Search Gallery”.
Via the search icon, type in Usercentrics and then select Usercentrics CMP
Click add to workspace, then click add
Now go to Tags, click New
Add a title to the tag (for example type in “Usercentrics CMP”)
Under Tag Configuration, Click Choose a tag type to begin setup
Using the search icon, type in and select Usercentrics CMP
Enter your Usercentrics Settings-ID. This can be found on the ‘view embed code’ page of your Termageddon License Cookie Policy and Consent Tool “View embed code” page (see highlighted example screenshot of a SettingsID here).
All other default settings can remain unchanged.
Under "Banner Version", select V2
Under Triggering, click Choose a Trigger to make this tag fire
Select Consent Initialization - All Pages
Click Save
You have now implemented the Google Certified Usercentrics CMP via the community templates feature. The next step will be to set up the consent overview along with events and triggers to ultimately capture consent on a per tag basis.
Step #3 - Enable consent overview
Consent overview provides a high level view of all the consent settings across the tags in your container. Although in Beta, it’s best to enable this feature for testing purposes later on in the documentation.
In your Google Tag Manager account, click Admin
Click Container Settings
Click/enable Enable consent overview (BETA)
Click Save
Step #4 - Set consent settings to “not set’
Navigate to Tags in the side-menu
Select a tag
Click the ‘edit’ icon for Tag Configuration
Click “Advanced Settings” -> “Consent Settings (BETA)”
Ensure “Additional Consent Checks” is set to “Not set”
NOTE: if you have already set up Basic consent mode and are switching over Advanced, you will need to revert your Tag’s Triggers back to their original settings. In other words, do not use the custom variables and triggers outlined in Step #4 for the Basic consent mode v2 setup.
Step #5 - Enable Consent Mode in your Termageddon account
If not enabled already, you will need to enable Consent Mode within your Termageddon license.
Log in (https://app.termageddon.com)
Click into your respective license
Click ‘edit policy details’ for the ‘Cookie Policy and Consent Tool’.
Click Enable for Google Consent Mode (on page 4)
Click ‘next’ several times and ultimately ‘submit’ for Consent Mode to be activated.
If not done already, this is also a good time to mark “Google Tag Manager” as “Essential” on the final page of the Termageddon “Cookie Policy and Consent Tool” questionnaire and click ‘submit’ for changes to take effect. To do this, click ‘edit’ next to “Google Tag Manager” and under “General”, change the “Category” to “Essential”. Google Tag Manager does not place cookies on a website by default, and since the Usercentrics consent tool needs to load to fulfil a compliance requirement, GTM will now be considered an Essential Service (and consent will still be captured on a per Service basis for other tags that fire from GTM).
Step #6 - Paste the GTM script above the Usercentrics script
For Advanced Consent Mode to work properly, you should have the Google Tag Manager script load first in the <head> before the Usercentrics script loads.
Step #7 - Test
Navigate to Tags in the side-menu and click Preview
A new tab will open, bringing you to Tag Assistant (tagassistant.google.com…)
Click Connect.
A new tab will open bringing you to your website.
Click back to the Tag Assistant browser window (tagassistant.google.com…..)
You should only see that the Usercentrics script has fired
Now in the other browser window (your website), within the cookie consent modal, click ‘more information’, and proceed with only accepting the “Google Analytics 4” Service, then click save settings.
Now head back to the Tag Assistant window, you should now see the Google Analytics 4 tag has now fired:
Click “consent” to view/confirm the proper “analytics_storage” consent has been granted
Go back to your website, and change your consent settings to ‘deny’
Go back to the Tag Assistant tab, and you should see that consent status has reverted back to denied. If you click ‘tags’, you will see Google Analytics 4 only fired one time (from when you first consented in Testing step #5 above).
Repeat testing for all respective Tags to confirm your consent tool (and Google Tag Manager) is properly responding to user consent choices.