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.