Google Tag Gateway enables you to serve Google scripts (e.g., gtm.js, gtag.js) from your own server or CDN rather than Google’s googletagmanager.com domain. This forces requests into a first-party context, which is critical for reducing third-party cookie loss and improving compliance under GDPR/CCPA.
1. Prerequisites
GTM Server Container already deployed.
Tagging server configured and mapped to a custom server domain (e.g., metrics.example.com).
DNS + SSL certs configured for that domain/subdomain.
2. Client Configuration (Server Container)
In GTM Server Container → Clients → New → Google Tag Manager: Web Container Client.
Enter the Web Container ID you use on the site.
Enable: Automatically serve all dependent Google scripts (recommended).
Optionally enable Region-specific settings to conditionally serve tags by geo.
Save and Publish.
3. Update GTM Install Snippet
Replace default Google script URLs with your first-party domain path:
html
<!-- HEAD -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://metrics.example.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXX');</script>
<!-- BODY (noscript fallback) -->
<noscript><iframe src="https://metrics.example.com/ns.html?id=GTM-XXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
This ensures all GTM requests hit your tagging server first.
4. Verification
Open DevTools → Sources in Chrome.
Confirm gtm.js is loaded from metrics.example.com instead of www.googletagmanager.com.
If still loading from Google, re-check snippet replacements and publishing status.
5. Notes on Performance & Cost
Routing all scripts via your tagging server increases server load and egress cost.
For high-traffic sites, use CDN Tag Gateway mode to offload bandwidth.
Only dependent Google tags transmitting to server-side GTM will be served first-party unless explicitly configured