Stape
Contact salesTry for free

Google Tag Gateway + Stape Gateway: first-party tagging setup

Faris

Faris

Author
Published
Jul 3, 2025

With more browsers blocking third-party tracking and ad blockers getting smarter, it's becoming harder to collect accurate website data. Google's First-Party Mode (called Google Tag Gateway) and Stape Gateway help solve this by letting you run tracking through your own domain. This means your tags look like part of your site, which helps avoid blocks and keeps your data more reliable. In this article, we'll explain how Google's and Stape's tools work, how they can be used together, and why this setup gives you better control and more accurate tracking across different platforms like Google, Meta, and TikTok.

Google's First-Party Mode overview 

What is Google's First-Party Mode? 

Google's First-Party Mode is a way to make Google tracking tools (like Google Tag Manager and Google Analytics 4) work as if they are part of your own website, instead of being loaded from Google's servers directly. This helps your tracking avoid being blocked by browsers or ad blockers, making your data more accurate and reliable.

Google's First-Party Mode, branded in the UI as Google Tag Gateway (GTG), lets you run Google tags on infrastructure you control. In practice, that means every GTM/GA4 request is re-routed through the servers or CDN  you own, rather than calling Google domains like googletagmanager.com

This ensures that Google's libraries and measurement endpoints are treated as first-party by browsers, enhancing data reliability and helping avoid disruptions caused by ad blockers or browser privacy mechanisms (such as ITP/ETP).

How Google's First-Party Mode works

Let's break down how it works step-by-step.

  1. First, you map a path on your domain (for example, /metrics or any prefix you prefer) in Cloudflare Gateway.
  2. Cloudflare Gateway forwards every request made to that path directly to Google’s endpoint behind the scenes. 

This setup lets you control the routing of Google tag requests through your own infrastructure, improving tracking reliability and privacy compliance.

Key benefits of Google's First-Party Mode

  • Improved ad blockers
  • Support for first-party cookies
  • Compatibility with any GTM-enabled site
  • Official support through Cloudflare Gateway

In short, Google's First-Party Mode routes tracking requests through your own domain to improve data accuracy and avoid disruptions caused by browsers or ad blockers. This makes your Google tags more reliable while keeping full compatibility with existing GTM setups.

Stape Gateway: a flexible, multi-platform first-party solution

Stape offers a powerful and flexible Gateway solution that lets you run tracking scripts and send data through your own domain. Unlike Google's built-in first-party mode, Stape supports tracking not just for Google tools like GA4 and Ads, but also for platforms like Meta, TikTok, Pinterest, LinkedIn, and more, all from your existing GTM setup.

With tools like Custom Loader (which hides gtm.js or gtag.js under your own subdomain), Stape helps you avoid ad blockers and browser limits, so your data stays more accurate. Plus, with full support for server-side GTM, longer-lasting cookies, and custom domains, Stape gives you more control and flexibility than Google's GTG solution.

Can Google's GTG be used with Stape?

Yes, GTG and Stape's Server GTM setup can coexist without interference. Whether you're just proxying Google's endpoints through GTG or routing all GA4/Ads data to your Stape container, both options can function together.

This is possible because:

  • GTG operates at the network layer, intercepting calls to Google domains and proxying them via Cloudflare.
  • Stape operates at the tagging level, allowing you to enrich, modify, and route events server-side through your server_container_url.

When using both:

  • GA4 hits can still be routed to your server container (e.g., sst.yourdomain.com/g/collect)
  • GTG will still initiate lightweight calls to /metrics/... for bootstrapping, usually via a service worker
  • These /metrics calls do not conflict with your main tracking and don't result in duplicate hits

Why consider Stape Gateway as the better choice?

While Google Tag Gateway is a solid solution for enabling first-party tracking within Google's ecosystem, it's limited to Google tools like GA4 and Ads.

Stape Gateway takes it a step further. It provides a platform-agnostic first-party infrastructure that works not only with Google but also with Meta, TikTok, Pinterest, LinkedIn, and more. With full control over tracking logic, data routing, and enrichment through server-side GTM, Stape is a future-ready solution for businesses that need flexible, cross-platform analytics without compromise.

GTG + Stape setup in action

Here's how Google's First-Party Mode works in combination with Stape's tracking infrastructure.

How to connect it:

1. In GTM → Admin → Google Tag GatewayCloudflare and select the domain.

GTG setup with Cloudflare
GTG setup with Cloudflare

2. Within Cloudflare, create an Origin Rule.

Create Origin Rules in Cloudflare
Create Origin Rules in Cloudflare

Summary of tests and results: 

1  |  Basic Google First-Party Mode (FPM)

  • Status: Confirmed working.
  • What you see: collect hits go to the new endpoint, as FPM proxies those calls through Cloudflare Gateway.
Collect hits go to the new endpoint, as FPM proxies those calls through Cloudflare Gateway
Collect hits go to the new endpoint, as FPM proxies those calls through Cloudflare Gateway
Collect hits go to the new endpoint, as FPM proxies those calls through Cloudflare Gateway
Collect hits go to the new endpoint, as FPM proxies those calls through Cloudflare Gateway

2  |  FPM with Stape Custom Loader + Custom domain

  • Status: Works; loader masks gtm.js with the custom domain 
  • Take-away: Loader + FPM coexist fine
Loader + FPM coexist fine
Loader + FPM coexist fine

Conclusion

Stape and Google Tag Gateway aren't mutually exclusive; they complement each other. GTG ensures Google tags load in a first-party context. Stape adds a layer of flexibility and platform support beyond Google, enabling true cross-channel server-side tracking.

Used together, they give you the best of both: Google-native first-party delivery and full control over data flows through Stape's Server GTM setup. Whether you're optimizing for privacy, accuracy, or long-term scalability, this hybrid approach covers all bases.

Want to start on server-side?Register now!

author

Faris

Author

Faris, a server-side tracking specialist, assists businesses in optimizing data accuracy and tracking setups. With expertise in GTM, he simplifies complex tracking for marketers and developers alike.

Comments

Try Stape for all things server-sideright now!