Google Consent Mode

How to implement Google Consent Mode v2 in Basic or Advanced mode in CookieOfficer

How to implement Google Consent Mode v2 in Basic or Advanced mode in CookieOfficer step by step: panel settings, default state, blocking and verification.

5 min read

In this article, we explain step by step how to implement Google Consent Mode v2 in CookieOfficer in Basic or Advanced mode. You will also learn how to set the default consent state, how script blocking works and how to check that the setup is correct. We describe the differences between the modes in the article "Google Consent Mode v2: Basic and Advanced mode".

Before you start

  • First, install CookieOfficer on your website. You can use the code from the "Installation" tab, the Google Tag Manager template or the integration for platforms such as Wix, Shopify, Webflow or Joomla.
  • Google tools such as Google Analytics 4 or Google Ads should be installed on the website.
  • The business owner chooses the mode, ideally together with the person responsible for personal data protection.

Step 1: turn on Google Consent Mode v2 in the CookieOfficer panel

  1. Go to "Settings" in the "Setup" section.
  2. In the "Integration with analytics and advertising tools" section, turn "Google Consent Mode v2" on.
  3. Select "Basic" or "Advanced" mode.
  4. Click "Save changes".

The CookieOfficer code sets the CookieOfficer ID at Google (Developer ID) by itself, so you do not have to enter it manually.

Step 2: set the default consent state before Google tools

For Google Consent Mode to work correctly, you first need to set the default consent state. You can do this in one of two ways:

Deployment methodSetting the default consent state
CookieOfficer codeThe default consent block from the "Installation" tab, placed in the <head> section before the Google tools code.
Google Tag ManagerThe "Enable Google Consent Mode" field turned on in the CookieOfficer template. Also turn it on in the panel (step 1) and select the same mode in the panel as in the template. Otherwise CookieOfficer may block Google tools that, in Advanced mode, should run before consent is given. We describe the setup in the article Setting up CookieOfficer with Google Tag Manager.

Remember the order. If you start Google tools before the default consent state is set, debug mode and "Verify setup" show a warning.

Setting up Basic mode

In Basic mode, Google tools start only after the user gives consent. How they are held back depends on the script blocking method you selected.

  • With automatic blocking, CookieOfficer holds back Google tools until the user makes a decision. The system blocks the tools it detects during the scan. The Google Tag Manager container is not blocked. When CookieOfficer is set up with Google Tag Manager, blocking starts only after the container loads. It will not stop tags that started earlier, so the most reliable way is to use the tag consent settings in Google Tag Manager.
  • Manual blocking: you have to hold back Google tools yourself. In the page code, add the attributes type="text/plain" and data-co-cat with the category key to the Google tag: analytics for Google Analytics 4, marketing for Google Ads. Enter the key in English. An unknown value, e.g. "Analityczne", will block the script permanently. In Google Tag Manager, open the Google tag, then in the "Advanced Settings" → "Consent Settings" section, under "Additional consent checks", select "Require additional consent for tag to fire" and add the consent type: analytics_storage for Google Analytics 4 or ad_storage for Google Ads. The built-in consent checks ("Built-In Consent Checks") do not stop the tag from firing. They only adjust how it works.

Example:

<script type="text/plain" data-co-cat="analytics" src="https://www.googletagmanager.com/gtag/js?id=G-XXXX"></script>

If you use manual blocking and do not hold back Google tools, they will start before the user makes a decision, even if Basic mode is selected.

Setting up Advanced mode

In Advanced mode, Google tools start right away. Until the user gives consent, they send only data without using cookies. The tools are not blocked, because the consent state determines how they work.

  • Set the default consent state before Google tools start (see step 2).
  • With automatic blocking, Advanced mode unblocks Google tools right away.
  • Behavioral modeling in Google Analytics 4 works only in Advanced mode.

How do cookie categories map to consent types?

CookieOfficer automatically maps each cookie category to the matching consent types. You do not need to set anything else.

Category in the cookie bannerConsent type in Google Consent Mode
Analyticsanalytics_storage
Marketingad_storage, ad_user_data, ad_personalization
Functionalfunctionality_storage, personalization_storage
Necessarysecurity_storage, always granted

The "Other" category has no equivalent in Google Consent Mode.

Step 3: check that the setup is correct

  1. In the panel, select "Verify setup" in the "Integration with analytics and advertising tools" section.
  2. Open the page in incognito mode and add the ?co_debug=1 parameter to the end of the URL.
  3. In the browser console, check which mode you selected and which order message appeared.
  4. Click "Accept", then check in the console whether the consent was updated.

We give the details in the articles Debug mode in CookieOfficer and Verifying the CookieOfficer setup on your site.

How to change the Google Consent Mode mode

You can change the mode in the CookieOfficer panel at any time.

  1. Go to "Settings" in the "Setup" section.
  2. Change the mode in the "Integration with analytics and advertising tools" block.
  3. Click "Save changes".
  4. Check the setup again using the instructions from step 3.

If you change the mode from Advanced to Basic and use manual blocking, remember to hold back Google tools by setting the type="text/plain" and data-co-cat attributes, or in the tag consent settings in Google Tag Manager.

Most common mistakes

  • Selecting the mode in the panel without saving the changes.
  • Basic mode will not work with manual blocking if you do not mark Google tags with the type="text/plain" and data-co-cat attributes or do not set consent in the Google Tag Manager tags.
  • The Google tools code is placed in the page code before the default consent block.
  • Different settings in the Google Tag Manager template and in the panel, e.g. Advanced mode in the template while Google Consent Mode is off or set to Basic mode in the panel. CookieOfficer then blocks the Google tools detected during the scan.

Frequently asked questions

Which mode should I choose?

The business owner decides on the mode. In the article "Google Consent Mode v2: Basic and Advanced mode", we describe how the modes differ and how they affect data.

In Advanced mode, do Google tools set cookies without the user's consent?

No. Before the user gives consent, Google tools send only the consent state and data, without using cookies.

Do I need to set anything to map a category to a consent type?

No. CookieOfficer sets the mapping by default.

Do I have to set the Developer ID myself?

No. The CookieOfficer code sets the CookieOfficer ID at Google automatically on every page.

Google documentation

Related articles

Didn't find an answer?

Write to us. We reply on working days, usually the same day.

Contact us