The Crisis of Client-Side Tracking
Traditional web tracking relies on third-party JavaScript tags firing inside the visitor's browser. With Safari ITP (Intelligent Tracking Prevention), iOS privacy restrictions, ad blockers, and network latency, client-side tracking loses 20% to 40% of conversion data. Server-Side Google Tag Manager (sGTM) moves the tracking pipeline onto your own Google Cloud infrastructure, routing all hits through a first-party custom domain (e.g. metrics.yourcompany.com).
1. Provisioning sGTM on Google Cloud Run
Google provides an automated Cloud Run provisioning script within Tag Manager:
- Inside Google Tag Manager, click Create Container and select Server.
- Choose Automatically provision tagging server or manual Cloud Run deployment.
- Select your Google Cloud billing project. GTM will spin up a Google Cloud Run service with a default testing deployment.
2. Configuring a First-Party Custom Domain
To eliminate third-party cookie blocking, map your tagging server to a subdomain of your main site:
- In Google Cloud Console, navigate to Cloud Run > Manage Custom Domains.
- Add a custom domain mapping for
metrics.yourcompany.com. - In your DNS provider (Cloudflare, Google Cloud DNS), add the required CNAME record pointing to
ghs.googlehosted.com. - In Tag Manager Container Settings, update the Server Container URL to
https://metrics.yourcompany.com.
3. Routing Client-Side GA4 through the Server Container
Update your existing client-side Web GTM container so the Google Tag routes requests through your private server endpoint:
// In Web GTM: Google Tag configuration parameter
server_container_url: "https://metrics.yourcompany.com"
All pageviews, scroll events, and transactions are now sent directly to your Cloud Run container, where you can redact IP addresses, scrub PII, and forward clean payloads to GA4, Google Ads, and Facebook Conversions API.
Frequently Asked Questions
How much does running server-side GTM on Google Cloud cost?
A single Cloud Run instance with minimum instances set to 0 costs approximately $5 to $15 per month for small sites. For high-availability multi-region enterprise deployments, running 3 warm instances costs approximately $100 to $150 per month.
Does server-side GTM improve website loading speed?
Yes. Instead of loading 10 separate third-party vendor tracking scripts on the client, the user's browser sends one single unified stream to your server container, drastically reducing JavaScript execution overhead and improving Core Web Vitals (INP and LCP).
Deploying Server-Side GTM on Cloud Run with Custom Subdomain CDN
For maximum performance and first-party cookie survival, map your Cloud Run server-side tagging container to a custom subdomain (e.g. metrics.yourdomain.com) using Cloudflare or Google Cloud Load Balancing.
By routing tagging traffic through your primary apex domain, the browser treats all tracking cookies as true first-party context, ensuring that Safari ITP does not cap cookie lifespan to 7 days, thereby preserving accurate 30-day conversion attribution in Google Ads.