Setting up Google tag gateway with CookieOfficer
How to set up Google tag gateway on a website with CookieOfficer: Advanced mode, script loading order, Cloudflare settings and checking the setup.
Google tag gateway is a Google mechanism that lets you load Google tools from your website's domain. In this article we describe how to set up Google tag gateway on a website that uses CookieOfficer. We also describe the recommended settings in the panel and how to check that the setup is correct. For an explanation of what Google tag gateway is and what it changes on your website, see the post What Google tag gateway is and what it changes on your website.
Before you start
- CookieOfficer must be set up on your website with the code from the “Installation” tab in the CookieOfficer panel or with the “CookieOfficer CMP” template in Google Tag Manager.
- Google Consent Mode must be turned on in the CookieOfficer panel, in the “Settings” tab.
- You need access to the Google tag settings (in Google Ads, Google Analytics or Google Tag Manager) and to the account in your CDN, for example Cloudflare, where your website's domain is connected. A CDN is a network of servers that stores a copy of your website and delivers it to users faster.
Google tag gateway and CookieOfficer
CookieOfficer can be used on websites with Google tag gateway. The table below describes how CookieOfficer features work when you use Google tag gateway. Pay particular attention to automatic blocking.
| CookieOfficer feature | Effect of Google tag gateway on the feature |
|---|---|
| Default consent state | The Google Consent Mode default consent state 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. |
| Consent update | The Google Consent Mode consent state is updated after the user's decision in the banner, the same as without Google tag gateway. |
| CookieOfficer identifier (Developer ID) | The identifier is added on every page, regardless of the address the Google tag is loaded from. Google uses it to recognize that the website uses CookieOfficer. |
| Scanner | Google cookies are recognized by name (e.g. _ga, _gcl_au) and assigned to Google, the same as without Google tag gateway. |
| Automatic blocking | Google tools loaded through Google tag gateway are not blocked automatically, because they come from your website's domain. That is why Advanced mode is recommended (step 1). |
Before the user's decision in the banner, Google tools loaded through Google tag gateway run with the Google Consent Mode default consent state. You can hold them completely in the tag consent settings in Google Tag Manager.
How to set up Google tag gateway on a website with CookieOfficer
Step 1: Choose Advanced mode for Google Consent Mode
- In the CookieOfficer panel, open “Settings” in the “Setup” section of the side menu.
- Go to the “Integration with analytics and advertising tools” block.
- Choose “Advanced” mode for Google Consent Mode.
- Click “Save changes”.
Advanced mode is recommended for tools loaded through Google tag gateway, because they are loaded from your website's domain and cannot be blocked automatically. In Basic mode, Google tools should be held until the user's decision in the banner, and with Google tag gateway this is not possible.
Step 2: Make sure the Google Consent Mode default consent state is added before Google tools
If Google tools run before the Google Consent Mode default consent state is added, cookies may be saved before the user's decision in the banner. You can make sure the order is correct in two ways:
Google Tag Manager container (recommended)
- Move all Google tools to the Google Tag Manager container where you have CookieOfficer set up with the “CookieOfficer CMP” template.
- Make sure the CookieOfficer tag uses the “Consent Initialization - All Pages” trigger.
- Set up Google tag gateway for the whole container (ID
GTM-XXXXXXX). - 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.
Manual setup
- In the CookieOfficer panel, open the “Installation” tab.
- In the “Deployment method” section, choose “Code on the site”.
- Copy the “Google Consent Mode: default consent” block.
- Open your website code, e.g. the page template or the theme settings in your CMS.
- Find the
<head>section. - Paste the copied block at the very beginning of the
<head>section, before the code of Google tools. - Save the changes and publish the website.
If you don't have access to the website code, pass this block to the person who manages the website.
Step 3: Turn off automated script setup in Cloudflare
With automated setup, Cloudflare places the code of Google tools in your website code. Google tools may then run before the Google Consent Mode default consent state is added. Google states that if you use Google Consent Mode, you must turn off automated script setup.
- In the Google tag settings, on the “Admin” → “Google tag gateway” page, choose “Guided” instead of the “Automated” option (selected by default).
- On all pages, change the Google tag script address to the Google tag gateway path given in Google's instructions.
Without changing the script address, the tag is downloaded directly from Google, and Google tag gateway is not used.
Google describes the setup in the article Set up Google tag gateway for advertisers in the Google tag with Cloudflare.
How to check that the setup is correct
- In the Google tag settings (in Google Ads, Google Analytics or Google Tag Manager), on the “Admin” → “Google tag gateway” page, check that the domain has the “First-party” status.
- In Tag Assistant, go to “Summary” → “Output” → “Hits Sent”. Check that the hits sent go to a path on your website's domain.
- Open the website with the
?co_debug=1parameter in an incognito window and open the browser console (F12 key). The console should not show a warning that the Google Consent Mode default consent state was added too late. - In the banner, click “Accept” and check the consent update in the console.
- In a new incognito window, reject consent and check that the consent types other than
security_storagehave the valuedenied. - In the CookieOfficer panel, click “Verify setup”. The check covers the home page.
We describe debug mode in the article Debug mode in CookieOfficer. If you see a warning that the Google Consent Mode default consent state was added too late, see the article Google tag gateway: Google tags running before the Google Consent Mode default state.
Common mistakes
- Leaving the “Automated” option in Cloudflare with Google Consent Mode turned on.
- Choosing Basic mode for tools loaded through Google tag gateway. These tools are not blocked automatically, so in Basic mode they will not be held until the user's decision in the banner.
- Choosing the “Guided” option without changing the Google tag script address on the pages.
- Not checking the setup after turning on Google tag gateway.
Google documentation
- Google tag gateway for advertisers
- Set up Google tag gateway for advertisers in the Google tag with Cloudflare
- Google tag gateway cookie handling
Related articles
- Google tag gateway: Google tags running before the Google Consent Mode default state
- How to implement Google Consent Mode v2 in Basic or Advanced mode in CookieOfficer
- Debug mode in CookieOfficer
- Setting up CookieOfficer with Google Tag Manager
- What Google tag gateway is and what it changes on your website
- Google Consent Mode: support and reporting issues