Server-Side GTM: Load All Google Scripts as First-Party

Since June 2025, the sGTM Web Container Client can serve gtm.js and gtag.js as first-party. Configuration, benefits, and HTTP compression.

Since June 2025, Google has consolidated how server-side GTM serves client-side scripts. The Web Container Client now handles both gtm.js and gtag.js, paving the way for fully first-party loading of all Google scripts. This evolution, documented by Simo Ahava, changes the game for tracking reliability.

The Web Container Client Consolidation

Before this update, loading gtm.js and gtag.js went through different mechanisms in server-side GTM. Now, a single component, the Web Container Client, handles both. This simplification makes configuration easier and ensures uniform behavior for all Google scripts loaded via your server container.

Two Methods for First-Party Loading

The first method involves loading each script individually from your server-side domain. You replace the standard loading URLs (googletagmanager.com, googletagservices.com) with your sGTM subdomain (for example sgtm.yoursite.com). Each script is then served from your own domain.

The second method, more elegant, uses the “Automatically serve all dependent Google scripts” option in the Web Container Client. Once enabled, all dependent Google scripts are automatically proxied through your server container. This approach covers scripts dynamically loaded by gtm.js, including those you might not have anticipated.

Google Tag Configuration

For the Google Tag to know it should load dependencies from your server, you need to configure the server_container_url parameter in your loading snippet. This parameter tells the tag your server-side container’s address. Without this configuration, the tag will continue loading scripts from standard Google domains. For a complete setup, see our guide on server-side tracking.

Concrete Benefits of First-Party Loading

Loading Google scripts from your own domain delivers three measurable benefits. First, requests are treated as first-party by browsers, bypassing Safari’s ITP restrictions and Firefox’s anti-tracking rules. Second, ad blockers targeting standard Google domains no longer block loading. Third, reducing requests to third-party domains improves perceived load time and Core Web Vitals metrics.

This approach is complementary to Google Tag Gateway and is a natural evolution for businesses already using a server-side container via Stape.

HTTP Compression and Performance

Server-side GTM can serve scripts with HTTP compression. On Cloud Run, compression must be configured manually at the load balancer level or via an upstream CDN. On App Engine, gzip compression is automatically enabled for compatible MIME types. In both cases, verify that Accept-Encoding and Content-Encoding headers are properly handled to minimize transfer sizes and optimize initial load time.

Need help with this topic?

I can help you implement or optimize your tracking setup.

Book a call