sGTM – Server Side Tracking

This guide shows you how to point GTM Kit at a server-side Google Tag Manager (sGTM) container instead of the default googletagmanager.com endpoint.

What this is for

A server-side GTM container runs on your own infrastructure (or a hosted provider like Stape) and proxies requests to Google Analytics, Meta, and other vendors from your domain. Two big benefits:

  • First-party cookies survive longer. Browser ITP rules cap third-party cookies aggressively but treat first-party cookies more leniently, so GA client IDs and similar persist better.
  • Fewer requests are blocked by ad blockers. Requests to googletagmanager.com are commonly blocked. Requests to metrics.yourdomain.com usually are not.

To use sGTM, you need:

  1. A running server container (self-hosted on Google Cloud Run, AWS, etc., or hosted via Stape, Addingwell, etc.).
  2. A custom domain or subdomain pointed at the container, for example metrics.example.com.
  3. The GTM container ID for the server container (a separate container from your web container).

GTM Kit does not host or operate sGTM for you. It points the snippet at your existing setup.

Steps

1. Set up your server container

Follow your sGTM provider’s onboarding. For Stape, that is at stape.io. For Google Cloud Run, see Google’s server-side tagging documentation.

The end state you need: a custom domain or subdomain (metrics.example.com) that responds to GTM container requests.

2. Open General settings

In WordPress, go to GTM Kit, General.

3. Enter the sGTM domain

In the sGTM Container Domain field, enter your custom domain. You can enter it with or without protocol; both metrics.example.com and https://metrics.example.com are accepted. The field validates that it resolves to a usable URL.

GTM server side

4. Save

GTM Kit will now load the GTM JavaScript from https://metrics.example.com/gtm.js?id=GTM-XXXXX and the noscript fallback from the same domain.

Stape-specific notes

GTM Kit ships with Stape support out of the box. If your sGTM Container Domain is a Stape domain, no additional configuration is needed; the rendered snippet uses Stape’s expected format.

For Stape’s Power-Up features (Cookie Keeper, custom loader paths, etc.), you may need to configure additional settings in the Stape dashboard. Those are documented at stape.io.

Verify it worked

View your site source. The container <script> should now reference your custom domain:

<script>(function(w,d,s,l,i){...
  j.src='https://metrics.example.com/gtm.js?id=GTM-XXXXXX';
...})(window,document,'script','dataLayer','GTM-XXXXXX');</script>

The <noscript> fallback should also point at the custom domain:

<noscript><iframe src="https://metrics.example.com/ns.html?id=GTM-XXXXXX"></iframe></noscript>

In DevTools, the Network tab should show requests going to metrics.example.com instead of googletagmanager.com.

Common issues

The custom domain returns 404. Your sGTM container is not running, or the routing rule for /gtm.js is missing. Check your provider’s status page or the Cloud Run service.

You get mixed content warnings. Your custom domain is not on HTTPS. sGTM requires TLS. Add a certificate via your provider or via Let’s Encrypt.

Tags fire to googletagmanager.com instead of your custom domain. That is your GTM workspace configuration, not GTM Kit. In your server container, edit each tag (GA4 client, Meta CAPI, etc.) and confirm they point at the right destinations. The web container’s job is just to send events to your sGTM domain; the server container is responsible for forwarding them.

You enter a domain and the field rejects it. Validation accepts hostnames or fully qualified URLs. Strip any trailing slash, query string, or path.