Integrating Google Consent Mode
Integrating Google Consent Mode with UCP you can respect the privacy choices of end users with minimal impact on your website's ad-based revenue stream, analytics, and more.
If you're already using Google gtag.js or Google Tag Manager (GTM) on your website, we recommend that you add the Google Consent Mode integration to your website, to ensure you get the best use of your Google Services.
The configuration described in this article works with the following Google tags deployed via gtag.js and 'Web' containers in Google Tag Manager:
- Google AdSense
- DoubleClick
- DoubleClick Bid Manager (formerly Invite Media)
- Channel Intelligence (Google)
- AdMeld (Google)
- Google AdWords
- Google Display Network
- AdMob (Google)
- Google Attribution 360 (formerly Adometry)
- Google Tag Manager
- Google Ad Services
- Google Mobile Ads
- Google IMA
- Google Ads
- Google Analytics
Benefits
Once you’ve implemented the integration on your website, UCP automatically signals the consent choices of your visitors to Google instead of blocking tags when not consented. Google uses the end user's granular consent to adjust tag behavior accordingly. For instance, this means serving personalized ads to visitors that have “opted-in” to marketing vendors and tracking, or instead serving general interest ads relating to the content of your website when a visitor signals an "opt-out".
Without the integration, no ads are typically served, as the scripts serving the ads aren’t allowed to run without consent from marketing vendors. With the Google Consent Mode and UCP integration in place, UCP allows tags to run and Google serves ads and log analytics data according to the UCP signal.
This article by Google describes the technical details of how supported tags change behavior based on the end user's consent.
Implementation
The Google Consent Mode is an API that UCP integrates with. Once you’ve installed the UCP tag on your site (directly or via the GTM Template Gallery), you can enable the Google Consent API-integration by adding the following code snippet to your UCP Script. You can find the script code here:
- From UCP, navigate to the Manage tab.
- From the top right part of the screen, click Get Site Notice Tag.
- From the Site Notice Tags drop-down, select Google Consent API.
- Copy the script code and paste into your UCP script.
Or copy and paste the script code here into your UCP script:
<script> window.dataLayer = window.dataLayer || []; if (typeof gtag !== 'function') function gtag(){dataLayer.push(arguments);} gtag('set', 'developer_id.dOGRkZj', true); gtag('consent', 'default', { 'ad_storage': 'denied', 'analytics_storage': 'denied', 'region': ['AT','BE','BG','CZ','DE','DK','ES','FI','FR','GB','GR','HU','IE','IT','LU','NL','PL','PT','RO','SE', 'BR', 'TH', 'TR'] }); </script>
Note: Make sure to add the above code before your gtag.js or GTM code snippet, and if you've chosen to rename the dataLayer, ensure that you change window.dataLayer to the actual name of the dataLayer.
Other considerations
- Google's API documentation suggests further steps to enable an integration, but as these are automatically handled by UCP, nothing else is needed. You may change the values of ad_storage and analytics_storage to 'granted' and set ads_data_redaction to 'false' if you want to default to an opt-in before the end user has submitted consent, for example allowing for a default opt-in under CCPA.
- If you are using UCP with Google Tag Manager today, you must remove any applied cookie consent triggers from Google tags that support Consent Mode (as listed above) and add a different trigger like "All pages".
- You need to add in the script to initiate the consent API in your page before any other Google tags are loaded. You can either add it to the UCP tag or directly to your page.