Using AdConsent with Google Tag Manager and Analytics
Overview
Google Consent Mode is a tool that syncs visitor consent choices with Google tags like Google Ads and Analytics. It adjusts data collection based on what a user prefers. If a user gives full consent, Google Analytics and advertising services can gather personalized data. If they opt out, only anonymized data is collected.
Google Consent Mode doesn't replace our Consent Management Platform (CMP), AdConsent. Instead, it makes sure that AdConsent works smoothly with Google tags, respecting user choices for ad personalization and remarketing.
Here’s a template to help you implement Google Consent Mode V2.
Manage Google Analytics Consent with Google Tag Manager Template
GTM Configuration
Enable Consent Overview
Go to your Tag Manager>Admin>Container Settings and make sure the Enable consent overview is enabled.
Go to Workspace>Tags. you will have a small shield in the top right corner.
Click on the shield to access Consent Overview.
Select your Google Analytics Tag and click the little shield.
Select Require additional consent for tag to fire (this will add an additional blocking layer to the tags) and select analytics_storage. For a deeper understanding of GTM Consent Mode settings, see https://support.google.com/tagmanager/answer/10718549#tag-settings.
Click Save.
Create Custom Triggers
Head to Triggers>New then choose Custom Event from the trigger options.
In the event name write
analytics_storage_consent_granted
and do the same for the title.Repeat the process for the
adconsentReady
custom event.
Implement the Snigel Consent Template
Download the latest version of
Snigel Consent Template
.Go to Templates>Tag Templates>New.
Click the three dots at the top right of the screen and select Import.
Select the
Snigel Consent Template
and click Save.
Setting the triggers for the tags
Go to Tags>New>Tag Configuration>Custom>Snigel Consent.
Give a name to your new Tag.
Click Tag Configuration if you don’t want to use the default settings. By default our consent template has the following options:
Wait for update: 500
Redact ads data: True
Click Triggering and select adConsentReady, Consent Initialization - All Pages, and Initialization - All Pages.
Click Save.
Click on your Google Analytics Tag.
Remove any trigger associated with it.
Click Triggering and select: analytics_storage_consent_granted.
Go to Tag firing options and select Once per page.
Click Tag Configuration.
Save.
Manage Google Analytics Consent with a Custom Script
Integration with Google Analytics 4
Google Tag Consent Mode requires setting the initial consent status to denied
and only updating it if the consent is granted. AdConsent will fire a signal to configure Google Tags Consent Mode with the user's consent choice when consent is available.
Configure Google Tag initial Consent Mode
Place the following script at the top of your page header before loading Google Tags. You need to add your own code in this script to configure Google Tags (eg: gtag events and configuration).
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('consent', 'default', {
'ad_storage': 'denied',
'ad_personalization': 'denied',
'ad_user_data': 'denied',
'analytics_storage': 'denied',
'wait_for_update': 1500
});
</script>
Load Google Tag
Load Google Tag and replace the parameter TAG_ID
with your own tag id in this example.
<script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script>
Use AdConsent to wait for the consent signal
Place the following script below the previous scripts in the page header. It will listen to AdConsent, wait for the user's consent choice, and update Google Tag Consent Mode.
<script>
window.addEventListener('adconsentReady', function() {
adconsent('getConsent', null, function(consent, success) {
if (success) {
if (consent.fullConsent) {
gtag('consent', 'update', {
'ad_storage': 'granted',
'ad_personalization': 'granted',
'ad_user_data': 'granted',
'analytics_storage': 'granted'
});
}
}
});
});
</script>
How to test
Using Tag Assistant to verify the implementation
Google Tag Assistant is a free browser extension that helps you debug and troubleshoot your Google Tag Manager (GTM) container and other Google tags like gtag. It can be particularly useful for verifying if your implementation adheres to the Transparency & Consent Framework v2 (TCF v2).
Here's how to use Tag Assistant to check for TCF v2:
Install Tag Assistant: Add the Google Tag Assistant extension to your browser from the Chrome Web Store (https://tagassistant.google.com/).
Verify Your Website:
Open the website where you've implemented TCF v2 with AdConsent.
Click on the Tag Assistant extension icon in your browser toolbar.
Check for Consent Events:
On the left side of the interface, you’ll have the Summary and all the events sent to GTM.
Review Consent Details:
Click on any "Consent" event to view detailed information regarding the specified event.
In the Output section, you will find a detailed overview of the Tags triggered during each event, including the frequency of their firing and any associated reasons for non-firing.
Go to Consent to confirm the different types of consent and their states on each event.
Possible values for consent state:
G100: No consent has been granted.
G110: Consent for Google Ads, but not for Google Analytics.
G101: Consent for Google Analytics, but not for Google Ads.
G111: Both Google Ads and Google Analytics have consent.
Confirm if consent signals are being provided
Go to Admin>Data collection and modification>Data streams within your analytics account.
Select the appropriate data stream.
Here, you can verify the status of data collection and ensure that consent signals are being transmitted correctly. Please note that it may take up to 48 hours for this information to become available.