Skip to main content
All CollectionsGoogle consent mode v2
Set up Google consent mode v2 by updating main installation code
Set up Google consent mode v2 by updating main installation code

Learn how to set up Google consent code v2 with Cookie Information by updating main installation code.

Updated over a month ago

In this article, we will walk you through setting up Google consent mode v2 with Cookie Information by changing the main installation code and consent popup template.

Before you start

Here are a few things to know before you start:

  • There are two different Google consent modes: basic and advanced. You can implement both in Cookie Information. The basic consent mode doesn’t allow you to collect any user data, not even consent status, until the user agrees. In the advanced consent mode, Google tags are loaded before the consent popup displays to users. Google collects cookieless data without personal identifiers.

  • To use Google advertising products, you need at least the basic mode installed. The advanced mode is optional.

  • To use Google consent mode v2, you must add a link to Google’s business data responsibility site in your consent template. The link must be visible on the first layer of the consent popup as soon as it is displayed. It shouldn’t be hidden behind any subpage or require additional clicks to access. This is needed no matter how you implement the consent mode v2. That way, users can easily reach that information.

  • To learn how to customize your template, see this style guide.

  • Here's the list of Google consent types and categories:

Consent type

Description

Consent category

ad_storage

Allows storage (such as cookies) related to advertising

Marketing

analytics_storage

Allows storage (such as cookies) related to analytics e.g. visit duration

Statistical

functionality_storage

Allows storage that supports the functionality of the website or app e.g. language settings

Functional

personalization_storage

Allows storage related to personalization e.g. video recommendations

Functional

security_storage

Allows storage related to security such as authentication functionality, fraud prevention, and other user protection

Necessary

ad_user_data

Sets consent for sending user data related to advertising to Google

Marketing

ad_personalization

Sets consent for personalized advertising

Marketing

Set up a basic Google consent mode v2

To set up a basic consent mode v2, follow these steps:


1. Log in to Cookie Information.


2. Go to Consent solutions.


3. Find the consent solution for which you want to change the consent popup template.


4. Navigate to Pop-up appearance and click the Template drop-down list under Change template.

5. Choose Overlay v2 - Google consent mode v2 and Overlay v3 - Google consent mode v2.

choose consent templates in Cookie Information


The default versions of overlay v2 and v3 without any customization, look like this:

Default consent popup examples in Cookie information

View our template showcase to see all template designs. To learn how to customize your template, see this style guide.

Note: Changing your template will reset any customizations including text or styling, you have made earlier.

6. (Optionally) If you use a different consent template or create a custom one, you need to add a link to Google’s business data responsibility site to meet Google’s requirements.

In Pop-up appearance, go to Advanced options and add the following code to your template’s HTML code:

​<a class="coi-banner__google-privacy-policy" aria-label="{{{translations.google_privacy_policy_link}}}" href="https://business.safety.google/privacy/" target="_blank">{{{translations.google_privacy_policy_link}}}</a>

7. Add the following code snippet to your website source code before the main installation code.

  <script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }

gtag('consent', 'default', {
'ad_user_data': 'denied',
'ad_personalization': 'denied',
'ad_storage': 'denied',
'analytics_storage': 'denied',
'wait_for_update': 500,
});
</script>

8. Make sure that the main installation code in the source code of your website contains data-gcm-version attribute with the value set to "2.0". We recommend placing the code in the <head> tag to ensure that the script is loaded first and the cookies can be blocked before consent has been given.

The main installation code will look like this:

<script id="CookieConsent" type="text/javascript" data-culture="EN" src="https://policy.app.cookieinformation.com/uc.js" data-gcm-version="2.0"></script>

Note: The attribute data-culture = "EN" controls the language in which the popup will appear on the page – in this example, it will be displayed in English. To change the language, set the data-culture attribute to a different language code. For more details, see this article.

Set up an advanced Google consent mode v2 (optional)

1. Instead of the basic mode snippet (see step 7. above), add the following snippet to your website source code before the main installation code.

 ​<script>​
window.dataLayer = window.dataLayer || [];
​function gtag() { dataLayer.push(arguments); }

​// Set default consent to 'denied' as a placeholder​
// Determine actual values based on customer's own requirements​

gtag('consent', 'default', {
​'ad_storage': 'denied',​
'ad_user_data': 'denied',​
'ad_personalization': 'denied',​
'analytics_storage': 'denied',​
'wait_for_update': 500
​});
​gtag('set', 'ads_data_redaction', true);
​gtag('set', 'url_passthrough', true);​
</script>

The final advanced mode setup should look like this:​

<script>​
window.dataLayer = window.dataLayer || [];
​function gtag() { dataLayer.push(arguments); }

​// Set default consent to 'denied' as a placeholder​
// Determine actual values based on customer's own requirements​

gtag('consent', 'default', {​
'ad_storage': 'denied',​
'ad_user_data': 'denied',​
'ad_personalization': 'denied',​
'analytics_storage': 'denied',​
'wait_for_update': 500​
});​
gtag('set', 'ads_data_redaction', true);​
gtag('set', 'url_passthrough', true);
​</script>​​

<script id="CookieConsent" type="text/javascript" data-culture="EN" src="https://policy.app.cookieinformation.com/uc.js" data-gcm-version="2.0">
</script>

Note: The code includes an enabled URL passthrough feature: gtag('set', 'url_passthrough', true). It’s optional. If you don’t want to use it, remove this line of code. For more details, see Google's documentation.

Related articles

Did this answer your question?