Implementation instructions

The instructions below are to implement proper consent 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 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:

  1. A Termageddon license, set up for GDPR and/or UK DPA and an activated Cookie Policy and consent tool. It is assumed the Usercentrics consent script is pasted immediately after <head> within the website (required just in general). 

  2. A Google Tag Manager account, with the regular GTM script added to the <head> of your website (just below the Usercentrics script).


Please note this is documentation to set up with Google Consent Mode V2.  This is not how to set up with the TCF framework.




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.


  1. Log into Google Tag Manager account and select the respective account (website or app) that you will be performing this update for.

  2. Click Templates on the left hand side


GTM Templates location


  1. For “Tag Templates”, click “Search Gallery”. 


GTM Search Gallery location


  1. Via the search icon, type in Usercentrics and then select Usercentrics CMP 


GTM location for Usercentrics CMP


  1. Click add to workspace, then click add



  1. Now go to Tags, click New

  2. Add a title to the tag (for example type in “Usercentrics CMP”)



  1. Under Tag Configuration, lick Choose a tag type to begin setup

  2. Using the search icon, type in and select Usercentrics CMP

  3. 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.

  1. Under Triggering, click Choose a Trigger to make this tag fire



  1. Select Consent Initialization - All Pages


  1. 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.


  1. In your Google Tag Manager account, click Admin



  1. Click Container Settings

  2. Click/enable Enable consent overview (BETA) 

  3. Click Save






Step #4 - Add the respective variables and triggers to your GTM account

Now we need to set up variables and triggers for the consent tool to respond to user consent choices and for those consent events to be properly captured within Google Tag Manager. This will allow us to set up triggers and then ultimately be able to update our tags to respond based on consent choices. 


The following Google Services currently support the Consent Mode:


Service

Usercentrics ID

Consent Type

Conversion Linker

LykAT-gy

ad_storage

Display & Video 360

UekC8ye4S

ad_storage

Google Ads

S1_9Vsuj-Q

ad_storage

Google Ads Conversion Tracking

twMyStLkn

ad_storage

Google Ads Remarketing

B1Hk_zoTX

ad_storage

Google Analytics

HkocEodjb7

analytics_storage

Google Analytics 4

87JYasXPF

analytics_storage

Google Campaign Manager 360

dyHOCwp5Y

ad_storage

Search Ads 360

DHS2sEi4b

ad_storage




DEPRECATED PRODUCT

Usercentrics ID

Consent Type

Doubleclick Ad 

9V8bg4D63

ad_storage

DoubleClick Floodlight

ByzZ5EsOsZX

ad_storage

Google Campaign Manager

pxiRY9112

ad_storage



Steps to add Variables

For this example, we will set up a Google Analytics 4 variable.  You will want to repeat this process for each Google Service you utilize within Google Tag Manager (see tables above).  Use the exact wording provided in the first column for the respective Google Service that you use (for example if you use Google Analytics 4, you must type that in exactly, not just Google Analytics, as that is technically a different Google Service).


  1. Navigate to Variables in the side-menu and then click on New.

  2. Name your variable. In this example, we will name it Google Analytics 4 Variable

  3. Add a new variable of type "Data Layer Variable".

  4. Under Data Layer Variable Name, insert Google Analytics 4.


⚠️ Note: Correct spelling, hyphenation and capitalization are mandatory for this field. Every technology must be added the way it is spelled in the Usercentrics Admin Interface. Here: "Google Analytics 4".


  1. Click/enable Set Default Value and type in false

  1. Click Save 


You have now set up the Google Analytics 4 variable.  Repeat this process for any other Google Services you use, outlined in the tables above. 


Steps to add Triggers

For this example, we will now set up a Trigger for Google Analytics 4.  You will want to repeat this process for each Google Service you utilize within Google Tag Manager (see tables above).  


⚠️ Note: There are several ways to implement this logic. Usercentrics recommends the following option, however, depending on your setup, other structures might be more reasonable.


  1. Navigate to Triggers in the side-menu and click on New

  2. Add a title to your trigger. For this example, we will type in “Google Analytics 4 Trigger”

  3. Click Trigger Configuration and select Custom Event

  4. Click/enable Use regex matching 

  5. Under Event Name, paste in (consent_status.*)

⚠️ Note: Correct spelling, hyphenation and capitalization are mandatory for this field.

  1.  Click/enable Some Custom Events

  2. In the drop-down menus, set the following condition: "Google Analytics 4 Variable" contains true.

Explanation: The variable contains the user's consent information (variable=true - user opted in || variable=false - user opted out) for a specific technology. Hence, the trigger should only be fired (and tag therefore activated), if the variable=true.

  1. Clicks Save



You have now set up the Google Analytics 4 trigger.  Repeat this process for any other Google Services you use, outlined in the tables above. 




Step #5 - Add new tags or update existing tags within your account with new triggers


  1. You can choose to pause your existing tags and create new ones, or you can modify your existing tags where you will remove the existing trigger and replace it with the new trigger. In this example, we will update an existing Tag.  You can still utilize the steps below if you are creating new tags (just remember to pause any existing tags prior to testing in the final step).

  2. Navigate to Tags in the side-menu and click on your Google Analytics 4 tag

  3. Remove the preexisting trigger(s) and replace it with the newly created “Google Analytics 4 Trigger”


  1. Click save



You have now set updated the Google Analytics 4 tag to fire only after a website visitor provides respectful consent.  Repeat this process for any other Google Services you use, outlined in the tables above. 




Step #6 - Enable Consent Mode in your Termageddon account

If not enabled already, you will need to enable Consent Mode within your Termageddon license.



  1. Log in (https://app.termageddon.com)

  2. Click into your respective license

  3. Click ‘edit policy details’ for the ‘Cookie Policy and Consent Tool’.  

  4. Click Enable for Google Consent Mode (on page 4)

  1. Click ‘next’ several times and ultimately ‘submit’ for Consent Mode to be activated.

    1. 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 #7 - Test


  1. Navigate to Tags in the side-menu and click Preview

    1. A new tab will open, bringing you to Tag Assistant (tagassistant.google.com…)

  2. Click Connect

    1. A new tab will open bringing you to your website.

  3. Click back to the Tag Assistant browser window (tagassistant.google.com…..)

  4. You should only see that the Usercentrics script has fired



  1. 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.



  1. Now head back to the Tag Assistant window, you should now see the Google Analytics 4 tag has now fired:



  1. Click “consent” to view/confirm the proper “analytics_storage” consent has been granted



  1. Go back to your website, and change your consent settings to ‘deny’

  2. 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).

  3. Repeat testing for all respective Tags to confirm your consent tool (and Google Tag Manager) is properly responding to user consent choices.