Google Tag Gateway and Cookie Consent: A Setup and Testing Guide
ON THIS PAGE
- What Is Google Tag Gateway and How Does It Work?
- How to Set Up Google Tag Gateway?
- Step 1: Check your existing tracking setup
- Step 2: Configure Google Tag Gateway settings
- Step 3: Choose your CDN / infrastructure provider
- Step 4. Define your measurement path
- Step 5: Select your website domains
- Step 6: Update hardcoded script references (if applicable)
- Step 7: Review tag installation and consent behavior
- How to Configure Cookie Consent with Google Tag Gateway
- How to Test and Troubleshoot Google Tag Gateway and Cookie Consent
- Frequently Asked Questions
Accurate website tracking is essential for understanding customer behavior, measuring conversions, and optimizing digital marketing campaigns. However, rising privacy expectations, browser restrictions, and Cookie Consent requirements limit user tracking.
Google Tag Gateway improves measurement by serving Google tags through your website's domain instead of relying entirely on requests to Google-hosted domains. This First-party approach bypasses browser blockers and increases conversion accuracy.
However, implementing Google Tag Gateway does not eliminate the need for Cookie Consent. Businesses must still collect Cookie Consent before setting cookies and ensure their tracking setup respects visitors' privacy preferences.
In this guide, we'll explain how Google Tag Gateway works, walk through the setup process, and show how to configure Cookie Consent using Google Consent Mode.
What Is Google Tag Gateway and How Does It Work?
Google Tag Gateway (GTG) is a reverse-proxy solution that allows you to load Google’s tracking scripts (such as GA4, Google Tag Manager, or Google Ads) directly from your own First-party infrastructure rather than from third-party Google domains.
Traditionally, Google Analytics and Google Ads tracking implementations load scripts and send measurement requests directly to Google domains.
Google Tag Gateway, officially called Google Tag Gateway for Advertisers, allows websites to load Google tags through their own domain. With Google Tag Gateway, your CDN (such as Cloudflare) or load balancer acts as an intermediary or reverse proxy on your domain.
The working principle of Google Tag Gateway involves three stages:
- A visitor opens your website
The browser requests Google tag through a designated path on your domain. - Your infrastructure processes the request
A CDN or reverse proxy retrieves the appropriate Google tag resources and forwards the requests to Google's measurement infrastructure using a configured content delivery network (CDN), load balancer, or web server. - Google processes the measurement data
The relevant Google services, such as Google Analytics 4 or Google Ads, depending on user consent settings, receive and process the information.
Key benefits of Google Tag Gateway include:
- GTG bypasses browser blockers
Because tracking requests originate from your own first-party domain instead of known ad-tech domains, they are less likely to be blocked by ad blockers or privacy extensions. - Higher conversion accuracy
Advertisers typically see higher conversion accuracy and conversion uplift (from 10% to 15% or more) due to reduced data loss. - Easier implementation
Unlike full server-side Google Tag Manager, GTG requires little to no custom server-side coding and can be enabled directly through providers like Cloudflare or a Google Cloud load balancer.
However, Google Tag Gateway doesn’t replace cookie consent. GTG changes how supported Google tags and measurement requests are delivered, but it does not determine whether a visitor has consented to analytics tracking, advertising tracking, or the processing of personal data. Thus, websites must still obtain and honor cookie consent, even when tracking requests originate from a first-party domain.
Google specifically advises businesses to review consent configurations when enabling Google Tag Gateway because the change can affect tag-loading behavior.
Google Tag Gateway also has some limitations:
- GTG does not replace server-side GTM
GTG cannot extend first-party cookie lifespans under strict browser rules (like Safari ITP) and can’t route non-Google tags, such as Meta Pixel). - IP forwarding consideration
Because Google receives your CDN's or server's IP address rather than the user's raw IP address, your infrastructure must properly collect and pass geolocation headers so Google can determine user regions accurately.
How to Set Up Google Tag Gateway?
Setting up Google Tag Gateway requires some infrastructure:
- Google Tag / GTM access
You need to have admin permissions on your Google Tag Manager or Google Ads/Analytics account. - Supported infrastructure / CDN
Implement a CDN or DNS provider (e.g., Cloudflare with Super Admin or Domain Admin privileges, Fastly, Akamai, or a Cloud Load Balancer). - An unused site path
You need to have a reserved first-party measurement path on your website (e.g., https://example.com/metrics or https://example.com/gtg).
The exact configuration depends on your website's hosting provider, CDN, and the integration method you select.
Use this step-by-step setup guide to set up GTG:
Step 1: Check your existing tracking setup
Before setting up GTG, confirm that your website already uses one of the following:
- Google Analytics 4 with a Google tag
- Google Ads conversion tracking
- Google Tag Manager
- An existing Google tag supporting your measurement configuration.
Also identify the CDN, load balancer, or web server that handles your website traffic.
Google provides setup options for infrastructure providers including Cloudflare, Akamai, Fastly, and Google Cloud, as well as a manual configuration route.
If your website already has a cookie Consent Management Platform (CMP), check how that platform controls your Google tags. This matters because enabling first-party tag delivery can affect existing script blocking.
Step 2: Configure Google Tag Gateway settings
You can launch the GTG setup flow from Google Ads, Google Analytics 4, or Google Tag Manager.
In Google Analytics 4, you can access your Google tag configuration through the Analytics interface:
- Sign in to Google Analytics.
- Open Admin.
- Navigate to Data streams and select your website's data stream.
- Select Configure tag settings.
- Open Google tag's Admin settings.
- Find the Google Tag Gateway setup option, if available for your configuration.
For Google Ads, navigate to Tools > Data manager > Google tag > Manage > Admin.
The interface may vary depending on your account and integration provider. If an automated setup option is available, follow the connection workflow to authorize your CDN provider.
Step 3: Choose your CDN / infrastructure provider
Google provides automated integrations for popular CDNs, as well as manual setup paths for custom architectures.
Provider integration is usually the simplest option for websites using a supported CDN. Select your provider (e.g., Cloudflare, Fastly, Akamai, or Google Cloud Load Balancer). Click Sign In to authenticate with your CDN platform and grant the necessary permissions for configuration.
You can also configure this manually. Websites with custom infrastructure can configure routing through a CDN, load balancer, or reverse proxy.
Step 4. Define your measurement path
Enter a reserved, unused URL path on your domain that will act as the proxy gateway.
Depending on your installation method, your CDN provider or server configuration may automatically establish this path. For a manual implementation, the path must be associated with the appropriate Google tag or Google Tag Manager container.
Google requires a unique serving path for each standalone tag or Tag Manager container. The path cannot be the root of the website and must meet Google's documented length and uniqueness requirements.
For example, the path could include: /metrics or /gtg
Change requests for scripts and telemetry from
[www.googletagmanager.com/gtm.js] (https://www.googletagmanager.com/gtm.js) to
[yourdomain.com/metrics/gtm.js] (https://yourdomain.com/metrics/gtm.js).
Step 5: Select your website domains
In the domain selection panel, choose the website domains where you want Tag Gateway to be active.
Click Done and then Complete Setup.
The platform will automatically deploy routing rules to route traffic sent to your measurement path directly to Google's endpoints.
Step 6: Update hardcoded script references (if applicable)
If you use GTM via the automated CDN integration, the edge integration will automatically override standard Google script requests on your domain.
If you have hardcoded gtag.js or gtm.js snippets in your HTML, you must manually update the source URL in your site code to use your new measurement path.
Old Script:
HTML
<script src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script>
Updated Script:
HTML
<script src="https://yourdomain.com/metrics/gtag/js?id=TAG_ID"></script>
Step 7: Review tag installation and consent behavior
After enabling Google Tag Gateway, check whether your installation method requires updating the Google tag snippet on your website.
Some provider integrations can perform parts of this configuration automatically, while manual setups may require changes to script URLs or routing rules.
Pay particular attention to automated script installation. Google advises disabling automated script setup when using consent mode so that you can maintain appropriate control over tag loading and consent initialization.
Avoid running multiple copies of the same Google tag, as duplicate installations can duplicate page views, events, or conversions.
Before publishing the updated setup, ensure your Consent Management Platform can still control tagging behavior based on visitors' choices.
Read more about setting up Google Tag Gateway for advertisers in Google Tag with Cloudflare.
How to Configure Cookie Consent with Google Tag Gateway
To manage cookie consent for tracking, websites can combine a Consent Management Platform (CMP) with Google Consent Mode v2. Consent Mode communicates users' privacy choices to Google tags, allowing their behavior to change based on user consent choices.
Cookie consent is a critical part of any Google Tag Gateway implementation. Although the gateway uses first-party infrastructure, it does not automatically manage user consent or guarantee compliance with privacy regulations such as the GDPR.
To manage cookie consent and comply with privacy laws, you need to combine a CMP with Google Consent Mode v2. Note that a CMP must be a Google-certified CMP, such as CookieScript.
Use these steps to configure cookie consent with Google Tag Gateway:
Step 1: Implement a Consent Management Platform
A Consent Management Platform (CMP) helps websites display a Cookie Banner and collect, store, and manage visitors' cookie preferences.
Read the detailed guide on how to install CookieScript CMP with Google Tag Manager.
Step 2: Configure Google Consent Mode v2
Google Consent Mode v2 has four important consent parameters:
| Consent parameter | Purpose |
| analytics_storage | Controls storage related to analytics, including analytics cookies. |
| ad_storage | Controls storage related to advertising. |
| ad_user_data | Communicates consent for sending user data to Google for advertising purposes. |
| ad_personalization | Communicates consent for personalized advertising. |
These parameters help Google tags determine how they should behave based on visitors' choices.
By default, these consent parameters should be blocked.
Most CMPs, such as CookieScript, block analytics and tracking scripts automatically.
For websites using a custom consent implementation with gtag.js, an example of denied default consent settings could be:
gtag('consent', 'default', {
'analytics_storage': 'denied',
'ad_storage': 'denied',
'ad_user_data': 'denied',
'ad_personalization': 'denied',
'wait_for_update': 500
}); This command should run before Google tag commands that send measurement data. It establishes an initial denied state until the website receives the updated consent decision.
Read the guide on how to implement and configure Google Consent Mode.
Step 3: Choose between basic and advanced consent mode
Google supports two main approaches to implementing consent mode: Basic and Advanced consent mode implementation.
In a basic implementation, Google tags are blocked until the visitor provides the required consent. If the visitor declines, blocked Google tags do not load or transmit measurement data.
In an advanced implementation, Google tags can load before consent is granted, with the appropriate consent defaults applied.
When consent is denied, supported tags may send limited, cookieless measurement signals. When consent is granted, their behavior changes according to the permissions provided.
Advanced Consent Mode supports more detailed conversion modeling, but you must evaluate its use against applicable legal requirements and your organization's privacy policies.
The actual implementation depends on your compliance requirements, CMP settings, and measurement needs.
Read more about basic vs. advanced consent mode and how to select one of them in your CMP.
Step 4: Verify that Google Tag Gateway respects consent choices
Once consent mode is configured, make sure the Google Tag Gateway implementation respects consent choices and does not interfere with the CMP's controls.
For example, a website using basic consent mode should not load a consent-dependent Google tag through its first-party gateway before user consent is granted.
For advanced consent mode, the gateway may serve supported tag requests while Google tags operate under denied consent settings. Some limited cookieless requests are allowed.
Test the following scenarios:
- Visitor accepts all cookies: The relevant analytics and advertising permissions are granted, and tags can operate accordingly.
- Visitor rejects optional cookies: Consent remains denied for the relevant purposes, so tags are not allowed.
- Visitor accepts analytics only: Analytics consent can be granted while advertising-related consent remains denied.
- Visitor withdraws consent: The website should update the consent state and apply its withdrawal policy, including blocking of rejected cookies.
The important principle is that first-party routing must not override user preferences. Even if GTG uses the first-party route, it must respect user consent choices.
Use CookieScript CMP to display a Cookie Banner and manage visitors' cookie preferences. CookieScript can be used together with Google Tag Gateway. It is also a Google-certified CMP with Gold tier status.
Features most directly relevant to this setup include:
- Cookie Banner: provides the interface for collecting visitor consent choices.
- Google Consent Mode v2: communicates visitor consent choices to supported Google services through consent types such as
analytics_storage,ad_storage,ad_user_dataandad_personalization. - Google Tag Manager integration: supports consent-aware Google tag configurations when GTM is part of the site’s measurement architecture.
- User consent recording: records visitor consent where consent recording is enabled.
- Consent events: allow application code to respond to consent actions and CMP events.
- Automatic script blocking: can prevent configured GTG non-essential scripts from running until the required consent is available.
- Geo targeting: allows consent configurations to vary according to visitor location.
- Cookie Scanner: identifies cookies that may need to be included in the site’s consent and blocking configuration.
CookieScript gives you a 14-day free trial of the Plus plan with no credit card required.
How to Test and Troubleshoot Google Tag Gateway and Cookie Consent
After setting up Google Tag Gateway and consent mode, test to ensure your tags work correctly and your implementation respects visitors' privacy decisions. Testing should cover both measurement accuracy and privacy behavior.
Step 1: Verify Google Tag Gateway requests
- Open your website in Google Chrome and launch Developer Tools.
- Navigate to the Network tab and reload the page.
- Use the search option to identify requests associated with your Google tag or first-party measurement path.
For example, if your configured measurement path is /metrics/, look for requests containing that path. Check whether:
- The expected Google tag script is loaded through your website domain when permitted.
- The requests return successful HTTP responses.
- Supported measurement requests use the configured first-party path.
- The browser console displays any script-loading or network errors.
Not every request associated with Google services will necessarily pass through Google Tag Gateway. Expected routing depends on your configuration and the requests the gateway supports.
If the tag still loads through its previous URL, review the installation method and check whether you should update your snippet.
Step 2: Test Consent Mode with Google Tag Assistant
Use Google Tag Assistant to test Google tags and consent behavior:
- Open Google Tag Assistant.
- Connect it to your website.
- Open your website in a fresh browser session.
- Review the detected Google tags and events.
- Inspect the consent information associated with the relevant events.
Check the consent states before interacting with the cookie banner. The consent parameters should be denied by default.
Next, accept some cookie categories (e.g. analytics or advertising) and check whether the consent values are updated correctly.
Then, reject cookies and check whether the consent parameters are also denied.
Check all four Consent Mode v2 parameters, particularly ad_user_data and ad_personalization.
You should also test across different browsers, devices, and website templates where possible.
Step 3. Inspect cookies and browser storage
Use Chrome Developer Tools to review the cookies stored by your website.
Open Application > Storage > Cookies and inspect the cookies associated with your domain. Pay particular attention to analytics and advertising cookies, including relevant Google Analytics cookies such as _ga.
Analytics cookies need consent, so these cookies should not be created before a user gives relevant permission.
After accepting analytics cookies, check that the expected cookies are created and behave correctly.
If a visitor withdraws consent, confirm that the CMP and your site's cookie management procedures block cookies.
Step 4. Verify events in Google Analytics 4
Once you confirm the gateway routes requests correctly and respects consent, review whether Google Analytics 4 receives the expected events.
Open your GA4 property and use DebugView or Realtime reports as appropriate.
Open a page, click a tracked button, or perform another action and check that the expected events appear and that they are not duplicated.
If an event doesn't appear, investigate whether consent restrictions, event configuration, gateway routing, or debugging settings are the cause.
Keep in mind that denied consent can intentionally limit what appears in analytics reporting. A missing event does not always indicate a technical malfunction.
Frequently Asked Questions
Does Google Tag Gateway require cookie consent?
Yes, Google Tag Gateway does not replace cookie consent requirements. Although it routes Google tags through your website's first-party domain, businesses must still obtain cookie consent. Implement a Consent Management Platform like CookieScript with Google Consent Mode v2 to ensure that analytics and advertising tags respect visitors' consent preferences.
How can I test whether Google Tag Gateway and cookie consent are working correctly?
You can test Google Tag Gateway using Google Tag Assistant and Chrome Developer Tools. Check the Network tab to verify that supported Google tag requests are routed through your first-party domain. Then, use Tag Assistant to confirm that Consent Mode v2 parameters update correctly when visitors accept or reject cookies. Additionally, check browser cookies and Google Analytics 4 events to identify tracking errors and consent issues.
Why are Google tags not loading through the first-party domain on Google Tag Gateway?
Possible causes include an incorrect measurement path, incomplete CDN configuration, or a website snippet that still references the previous tag installation. Review the gateway setup and confirm that the expected requests are routed through your configured path.
What to do if analytics cookies are created before consent?
This may indicate that consent defaults are configured too late, that a tag is not respecting consent restrictions, or that another tracking implementation is creating cookies independently. Check the order of consent initialization and review all tracking scripts, not just Google tags.
Compare CMP prices and features side by side
Pick up to 4 consent platforms, set your number of websites and see yearly prices, pageview limits and features in one view.
- Yearly prices for 1 to 200 domains
- Pageview limits and extra fees
- Features and customer reviews