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.comare commonly blocked. Requests tometrics.yourdomain.comusually are not.
To use sGTM, you need:
- A running server container (self-hosted on Google Cloud Run, AWS, etc., or hosted via Stape, Addingwell, etc.).
- A custom domain or subdomain pointed at the container, for example
metrics.example.com. - 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 Setup
In WordPress, go to GTM Kit → Setup.
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.
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
If your server container is hosted on Stape, GTM Kit can load it through Stape’s custom loader and use Stape’s Cookie Keeper. All three settings are under GTM Kit → Setup → Server-side Tagging (sGTM), below the sGTM Container Domain.
sGTM container identifier
Enter your Stape container identifier here to use Stape’s custom loader instead of the standard gtm.js path. It is the eight-character identifier of your Stape container. If your site already loads a Stape loader such as https://metrics.example.com/abcdefgh.js?st=GTM-XXXXXX, it is the part before .js.
Do not enter the file name of a loader Stape has issued, which is four characters longer (for example 1a2babcdefgh). GTM Kit uses the identifier to ask Stape for that loader, and Stape does not recognise the longer form.
Get the loader from Stape
Stape issues each container its own loader, with a file name and query that do not contain your container ID in readable form, so ad blockers find it harder to recognise than the standard one. Switch on Get the loader from Stape to use it. The setting is available once the sGTM Container Domain and the sGTM container identifier are filled in, and not while the Google tag gateway is on.
GTM Kit asks Stape for the loader when you save a change to those settings, or when you press Refresh loader. It never asks on a schedule or when a visitor opens a page. The request contains your container identifier, container ID, sGTM Container Domain and data layer name, plus the Cookie Keeper cookie name when Cookie Keeper is on. It contains no visitor data. The line under the setting tells you which loader your pages use and when it was fetched.
If Stape cannot be reached or returns no loader, your pages keep the standard loader, which still works, and the screen says so. Try again, or choose Paste the code instead and paste the Google Tag Manager code Stape shows for your container into Code from Stape. The code must be for your sGTM Container Domain.
GTM Kit never adds Stape’s code to your pages. It reads the loader address from it and writes its own snippet, so your data layer name, GTM environment and consent platform settings keep working.
Cookie Keeper
If you have set up Stape’s Cookie Keeper power-up, switch on Cookie Keeper (for Stape users only). Safari 16.4 and later then load your container from the address Cookie Keeper needs, so Stape can keep cookies longer than Safari normally allows. It needs the sGTM container identifier, and works with both the standard Stape loader and the one Stape issues. See Safari ITP and cookie lifetime for why this matters.
The power-up itself is set up in your Stape account. See 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>
With a Stape custom loader, the address ends in your container identifier or in the file name Stape issued instead of gtm.js, for example https://metrics.example.com/abcdefgh.js?st=GTM-XXXXXX. With the loader Stape issues, the query does not contain your container ID. Both are expected.
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.
Get the loader from Stape keeps the standard loader. Check that the sGTM container identifier is the eight-character identifier, not the longer file name of an issued loader, and that the sGTM Container Domain is the one your Stape container uses. Then press Refresh loader, or paste the code Stape shows for your container instead.
The dashboard says your pages are using the standard Server-side Tagging loader. Get the loader from Stape is switched on, but GTM Kit has no loader from Stape stored for this site, so your pages use the standard loader. Open Server-side Tagging and click Refresh loader to get the loader Stape issues.