To capture valuable insights while protecting user privacy, you need to collect consent from your website users. We recommend you use a Consent management platform (CMP) or work with your content management system (CMS) to collect consent and send it to Google.
Learn more about how to Set up your consent banner with a consent management platform or a content management system.
Step 1: Set up a consent banner
Scan a website
- Sign up for a OneTrust account.
- Scan your website to determine which cookies are being dropped. This is done from the Websites screen.
Categorise cookies
- From the 'Categorisations' screen, categorise the cookies based on their function. The category a cookie is put in will determine how it’s handled, so make sure that Google cookies are categorised according to your company’s requirements.
Create website templates
- After you’ve categorised the cookies on your site, navigate to the 'Templates' screen and create a template for 'Cookie banner', 'Preference Centre' and 'Cookie list'. There are pre-configured templates to support compliance for the various consent frameworks. Choose the template that fits your compliance needs.
Create and assign Geolocation Rule Groups
- After you’ve created a 'Template', navigate to the 'Geolocation Rules' screen and use that template to create a 'Geolocation Rules Group''. These settings will allow you to comply with consent requirements based on region, country or state.
- After you have defined your Geolocation Rules Group, assign it to your 'Domains'.
- Confirm whether the banner should be opt-in or opt-out in each region that you configure, and double-check that consent mode is turned on in the region(s) where you intend to use it, with appropriate purposes assigned to each of the available consent types.
Step 2: Set up consent mode
Set up using Google Tag Manager
- Open Google Tag Manager and navigate to your container.
- In 'Tags', click New and name your tag.
- Click Tag Configuration, then click Discover more tag types in the Community Template Gallery. From the gallery, search for 'OneTrust' and install 'OneTrust CMP' by OneTrustCMP.
- In OneTrust cookie consent, go to Integrations, then select Scripts and select your website from the list.
- Go to Production scripts and copy the ID from the first code box. From the code box, copy the bolded portion below. Your code will differ from the example provided.
https://cdn.cookielaw.org/consent/1edbd598-c92a-49e7-ad81-d9a3b1f9ef60/OtAutoBlock.js
- Navigate back to Tag Manager and paste your ID into the Data Domain script box.
- Toggle 'Do you want to use Google consent mode?' to 'Yes'.
- Click Add GCM Category one time for each of the following values, then set the default consent that you would like to use globally (including in places without privacy regulations).
- ad_storage
- analytics_storage
- ad_user_data
- Ad_personalization
- For alternative settings, such as defaulting consent to denied in some locations, click Add region-specific default. Select the default settings that you want for each of the listed consent types. In the first box, add the list of countries these defaults should apply to, using codes from the ISO standard list. You can review a list of European countries in the EU and EEA.
- Click Add, then click Triggering.
- Select 'Consent Initialisation – All Pages', then click Save.
- Click Preview in the top right-hand corner to test your container. View instructions for testing below.
- Publish your container.
Set up using another platform or directly from your website’s code
- From OneTrust, choose your website from the 'Integrations' section and select Scripts.
- Copy the code from the first text box in Production scripts.
- If you use a website builder, review their documentation to find out how to implement code in the 'head tag' of each page. Otherwise, skip to step 4.
- In the
<head>
tag of each page (review the instructions above if you use a website builder), paste the following code, followed by the CMP script you copied earlier at the very top of the<head>
tag. Note that this step is critical in order to ensure that the CMP functions properly.
<script>
// Define dataLayer and the gtag function.
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
// Set default consent for specific regions according to your requirements
gtag('consent', 'default', {
'ad_storage': 'denied',
'ad_user_data': 'denied',
'ad_personalization': 'denied',
'analytics_storage': 'denied',
'regions':[<list of ISO 3166-2 region codes>]
});
// Set default consent for all other regions according to your requirements
gtag('consent', 'default', {
'ad_storage': 'denied',
'ad_user_data': 'denied',
'ad_personalization': 'denied',
'analytics_storage': 'denied'
});
</script>
<!--Banner script here!-->
- Publish your site.
Testing using Tag Assistant
Learn more about how to Troubleshoot consent mode with Google Tag Manager.