Troubleshooting

Google tag gateway: Google tags running before the Google Consent Mode default state

A warning that the Google Consent Mode default consent state was added too late with Google tag gateway. How to recognize the cause and fix the problem in CookieOfficer.

6 min read

In debug mode, in “Verify setup” or in Tag Assistant, you may see a warning that the Google Consent Mode default consent state was added too late. The Google Consent Mode default consent state is the set of initial values of the consent types (e.g. analytics_storage and ad_storage) that apply until the user's decision in the banner. The warning means that Google tools ran before these values were added. The most common cause is Google tag gateway with automated setup in a CDN, e.g. Cloudflare. A CDN is a network of servers that stores a copy of your website and delivers it to users faster. In this article we describe how to check the cause and the possible solutions.

Why the Google Consent Mode default consent state is added too late

The Google Consent Mode default consent state must be added before Google tools run. It is added depending on how CookieOfficer is set up. With a manual setup, it is added by the “Google Consent Mode: default consent” block in the website code, and with Google Tag Manager, automatically by the CookieOfficer tag.

With automated setup, the CDN places the code of Google tools in your website code. The website owner then has no control over the order in which scripts load, and Google tools may run before the default consent state is added.

StepCorrect orderOrder with automated setup
1The Google Consent Mode default consent state is addedGoogle tools placed in the website code by the CDN run
2Google tools or the Google Tag Manager container runGoogle tools read consent before the default consent state is added
3The consent state is updated after the user's decision in the bannerThe Google Consent Mode default consent state is added, but too late

How to recognize the problem

  • Debug mode: open the website with the ?co_debug=1 parameter added to the address and open the browser console (F12 key). The console will show a warning with a link to this article. We describe debug mode in the article Debug mode in CookieOfficer.
  • CookieOfficer panel: the warning appears after you click “Verify setup” in the “Settings” tab, in the Google Consent Mode row, or “Verify now” in the “Installation” tab. The check covers the home page.
  • Tag Assistant: an error about the default consent state being added too late appears.

Warning text in the console:

[CookieOfficer debug] The Google Consent Mode default state was set too late: a Google tag read consent before it. Common causes: Google tag gateway or a Google tag placed above the default consent block. How to fix it: https://cookieofficer.com/help/troubleshooting/google-tag-gateway

Warning text in the panel:

The default consent state (default) is set too late, only after Google tags run. Check whether the tag is added through Google tag gateway (GTG). How to check and fix it

The information about the delay in debug mode and in the panel comes directly from the Google tag.

How to check whether Google tools are loaded through Google tag gateway

You can open the “Google tag gateway” page in one of three Google tools:

ToolPath
Google Ads“Tools” → “Data manager” → “Google tag” → “Manage” → “Admin” → “Google tag gateway”
Google Analytics“Admin” → “Data streams” → choose a stream → “Configure tag settings” → “Admin” → “Google tag gateway”
Google Tag Manager“Google tags” tab → tag name → “Admin” → “Google tag gateway”

On this page, check the status of your website's domain:

Domain statusMeaning
“First-party” or “Active”Google tag gateway is active.
“Not started”Google tag gateway has not been turned on yet.
“Paused”Google tag gateway is paused.
“Pending”Google tag gateway is turned on, but diagnostic data has not reached Google yet.

The second way to check is Tag Assistant:

  1. Open Tag Assistant and connect to your website.
  2. Go to “Summary” → “Output” → “Hits Sent”.
  3. Check that the hits sent go to a path on your website's domain, not to a Google domain.

How to fix the Google Consent Mode default consent state being added too late

You don't need to turn off Google tag gateway. It is enough to use one of the solutions below. In each of them, Advanced mode is recommended for Google Consent Mode, because Google tools loaded through Google tag gateway are not blocked automatically. You choose the mode in the CookieOfficer panel: “Settings” → “Integration with analytics and advertising tools” block.

Solution A: all Google tools in one Google Tag Manager container (recommended)

  1. Move all Google tools to the Google Tag Manager container where you have CookieOfficer set up with the “CookieOfficer CMP” template.
  2. Make sure the CookieOfficer tag uses the “Consent Initialization - All Pages” trigger.
  3. Turn on “Enable Google Consent Mode” in the CookieOfficer tag and Google Consent Mode in the CookieOfficer panel, in the “Settings” tab.
  4. Set up Google tag gateway for the whole container (ID GTM-XXXXXXX).
  5. Publish the container.

The CookieOfficer tag will run first, and the other tags will run with the Google Consent Mode default consent state already set. We describe importing the template in the article Setting up CookieOfficer with Google Tag Manager. Google describes setting up Google tag gateway for a container in the article Set up Google tag gateway for advertisers in Google Tag Manager with Cloudflare.

Solution B: turning off automated script setup

Google states that if you use Google Consent Mode, you must turn off automated script setup in the CDN.

  1. In the Google tag settings, on the “Admin” → “Google tag gateway” page, choose “Guided” instead of the “Automated” option.
  2. On all pages, change the Google tag script address to the Google tag gateway path given in Google's instructions.
  3. In the CookieOfficer panel, open the “Installation” tab, in the “Deployment method” section choose “Code on the site” and copy the “Google Consent Mode: default consent” block.
  4. Paste the copied block into your website code, at the very beginning of the <head> section, before the code of Google tools.
  5. Save the changes and publish the website.

Without changing the script address, the tag is downloaded directly from Google, and Google tag gateway is not used. If you don't have access to the website code, pass these steps to the person who manages the website.

Additional safeguard: limiting data transmission in the Google tag settings

This setting does not fix the script loading order. It only lets you limit the scope of data sent to Google before the user's decision in the banner.

  1. Open the Google tag settings. We give the paths in the section “How to check whether Google tools are loaded through Google tag gateway”.
  2. Click “Manage data transmission” (Data Transmission Controls).
  3. In the “Restrict advertising data transmission” section, choose “Transmit limited advertising data only” or “Don't transmit any advertising data”.

In “Additional settings” you can also block the transmission of behavioral analytics data and consent diagnostics data. The setting requires Google Consent Mode to be turned on, and you can change it only in the Google tag settings, not in the website code. In Google Analytics, the “Editor” role is required.

How to check that the fix works

  1. Clear the cache in the CDN, e.g. in Cloudflare.
  2. Open the website with the ?co_debug=1 parameter in an incognito window and open the browser console (F12 key).
  3. Check that the console does not show a warning that the Google Consent Mode default consent state was added too late.
  4. In the CookieOfficer panel, click “Verify setup”.
  5. In Tag Assistant, check that the error about the default consent state being added too late no longer appears.

The problem without Google tag gateway

The Google Consent Mode default consent state can be added too late also without Google tag gateway. The cause is then most often the order of the code on the website. The “Google Consent Mode: default consent” block must be at the very beginning of the <head> section, before the code of Google tools.

Common mistakes

  • Turning off Google Consent Mode to remove the warning. Google tools then run without information about the consent state.
  • Choosing Basic mode with Google tag gateway. Google tools loaded from your website's domain are not blocked automatically.
  • Choosing the “Guided” option without changing the Google tag script address on the pages.
  • Checking the fix without clearing the cache in the CDN.

Frequently asked questions

Should I turn off Google tag gateway?

No. You can use each of the solutions with Google tag gateway turned on.

Does the problem affect only Cloudflare?

No. The problem can occur in any CDN that places the code of Google tools automatically. It most often affects Cloudflare, because Google offers one-click setup with Cloudflare.

What should I do if the problem persists?

Contact us through the contact form. In your request, give the website address and the debug mode result. See the article Google Consent Mode: support and reporting issues for details.

Google documentation

Related articles

Didn't find an answer?

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

Contact us