Implementing Server-Side GTM on Google Cloud Run
Server-Side GTM on Google Cloud Run
📌 Introduction
A high-traffic media publisher needed to future-proof their tracking infrastructure against increasing browser privacy restrictions and ad blockers, which were blocking their client-side GTM tags on up to 35% of sessions.
❗ The Problem
Client-side GTM was being blocked by Safari ITP, Firefox ETP, and popular ad-blocking browser extensions. This meant 35% of sessions had no analytics data and key conversion events were being missed entirely. Data quality was deteriorating year over year.
🔍 Identifying the Causes
All tracking relied on first-party JavaScript loaded via third-party domains (google-analytics.com, googletagmanager.com). These domains are on blocklists used by most major ad blockers and are restricted by browser privacy features. There was no fallback mechanism.
⚠️ Consequences for the Business
30-35% of conversion data was simply missing. Ad platforms were under-reporting conversions and smart bidding was not performing optimally. The publisher's advertiser reporting showed lower impression-to-conversion rates than were actually occurring.
✅ Solution
Deployed server-side GTM on Google Cloud Run using a custom first-party subdomain (stm.publisherdomain.com). All tracking requests were routed through this first-party endpoint, making them indistinguishable from the site's own traffic. Migrated all critical tracking tags to the server container.
📈 Results
Tracked sessions increased by 31% as previously blocked tracking was recovered. Conversion event reporting improved by 28%. Page load speed improved by 340ms as heavy client-side scripts were removed. Ad platform ROAS reporting became more accurate.
🏁 Conclusion
Server-side GTM on a first-party subdomain is the most durable tracking architecture for the modern privacy era. The performance and data quality benefits compound over time as browser restrictions increase.
💡 Key Takeaways
Use a subdomain of your own domain (e.g., stm.yourdomain.com) for the server container to maximize first-party cookie lifetimes. Cloud Run is cost-effective for most traffic volumes. Migrate the most critical events first and validate before migrating all tags.
Talk to Us, It's Free
We are always willing to help. Let us know what you are looking for, and we will develop a unique solution for you.
Thank You!
Your message has been sent successfully. We'll get back to you soon.
Business Hours
Our support Hotline is available 24 Hours