Server-Side GTM Hosting
AxiTrace runs Google's official server-side Google Tag Manager (sGTM) container for you - hosted, patched, and kept alive - on the same custom tracking domain you already connected to AxiTrace. No new DNS record, no Cloud Run bill of your own, and nothing to register with Google.
- What is server-side GTM & why it matters
- Prerequisites
- Create a server container in GTM
- Manually provision the tagging server
- Copy the Container Config
- Paste it into AxiTrace and enable
- Wait for the deployment to go Live
- Register your tagging server URL in GTM
- Point the web container's Google tag at your server
- Configure tags inside your server container
- Verify with GTM Preview
- Serve Google scripts from your own domain (optional, strongly recommended)
- Troubleshooting
- FAQ
What is server-side GTM & why it matters
Server-side Google Tag Manager runs your GTM container on a server instead of inside the visitor's browser. Instead of every tag firing directly from JavaScript in the page, your site sends events to your own first-party tagging server, and that server fires the tags out to Facebook, Google Ads, GA4 and everyone else on your behalf.
That matters for three reasons:
-
First-party context. Requests to your tagging server travel over the same custom
domain your visitors already trust (the one you connected to AxiTrace) - not a third-party
googletagmanager.comorgoogle-analytics.comhostname. - Ad-blocker resilience. Browser extensions and privacy tools increasingly block well-known third-party tag-management hostnames by reputation. A first-party server endpoint is far less likely to be on any blocklist.
- Data control. Your server container is the single point where every outbound tag request passes through - you decide what data leaves, and can strip, hash or enrich it before it reaches any ad platform.
sGTM is normally either self-hosted on Cloud Run/App Engine (your own GCP bill, your own maintenance) or sold as a paid add-on by third-party tracking vendors. AxiTrace hosts and runs it for you at no extra cost on the Business plan, already wired into infrastructure you have already set up.
Prerequisites
Before you start, make sure you have:
- An AxiTrace Business plan or higher (Business or Custom). The feature and its setup instructions are visible on every plan, but only Business/Custom can actually enable a deployment - see pricing.
- A connected and verified custom tracking domain on the workspace, with AxiTrace routing fully live (status: Live) - not just pending verification. Server-side GTM hosting rides this exact domain; see the Domain Configuration guide if you have not set one up yet.
- A free Google Tag Manager account - the same one you would use for browser-side tags. No paid GTM tier exists; the server container feature is available to everyone.
Create a server container in GTM
In your own Google Tag Manager account (tagmanager.google.com), go to Admin → Create Container, give it a name, and choose Server as the target platform.
Manually provision the tagging server
GTM will ask how you want to provision the tagging server. Choose “Manually provision tagging server” - you do not need Google's automatic Cloud Run provisioning flow, since AxiTrace hosts the server for you.
Copy the Container Config
After choosing manual provisioning, GTM shows a Container Config value. Copy the whole string - this is the only value AxiTrace needs from your GTM account.
Paste it into AxiTrace and enable
In your AxiTrace workspace, open Connections → Server-Side GTM Hosting, paste the Container Config value into the field, and click Enable server-side GTM hosting.
Wait for the deployment to go Live
AxiTrace provisions your container in the background. Expect up to ~15 minutes before the status flips to Live - the status widget on the Connections page updates on its own, you do not need to keep the page open. This is the normal async deploy model (a background reconcile tick plus infrastructure propagation delay), not a failure.
Register your tagging server URL in GTM
Once the deployment is Live, AxiTrace's Connections page shows your exact tagging server URL - it is the same custom tracking domain already connected to AxiTrace, with a copy-to-clipboard button next to it. Nothing to type or invent. Add that exact URL to your server container's Server container URLs list: GTM Admin → Container Settings → Server container URLs.
Point the web container's Google tag at your server
In your web GTM container (the one running in visitors' browsers), edit your Google tag and set its Server container URL field to the same tagging server URL from Step 6. This is the setting that actually redirects browser traffic to your AxiTrace-hosted server container - without it, tags keep firing directly instead of routing through the server.
server_container_url parameter, set to the same tagging server URL from Step 6. Click to enlarge.Configure tags inside your server container
Your server container starts out empty. Its clients accept the incoming hits, but nothing is actually forwarded to Google Analytics until you add a server-side tag for it. This chapter takes about 5 minutes.
Open Connections → Google Ads in this workspace. If it already has a conversion action configured, AxiTrace is already delivering your purchase conversions to Google Ads server-side, GCLID-matched, through the Google Ads API - a separate, dedicated Offline conversion action. Google does not deduplicate conversions across different conversion actions, so for that workspace your complete server container setup is just this:
| Tag | Action | Why |
|---|---|---|
| GA4 tag | ✅ REQUIRED - the only tag you need | Forwards your GA4 events to your GA4 property. |
| Conversion Linker | ⛔ SKIP | Only useful alongside a server-side Google Ads tag, which you are not adding. Harmless if added, but does nothing here. |
| Google Ads Conversion Tracking tag | ⛔ DO NOT ADD | AxiTrace already delivers this purchase conversion server-side. Adding it here creates a third, duplicate path and double-counts every purchase. |
Then: Submit the container and confirm users appear in GA4 → Realtime within a minute or two - you are done, skip the optional block further below.
Only if this workspace's Google Ads connection has no conversion action configured (you are not using AxiTrace's built-in Google Ads conversion upload) should you also add the Conversion Linker and Google Ads Conversion Tracking tags - see the optional block below for those instructions.
Add a GA4 tag
In your server container, go to Tags → New and choose the Google Analytics: GA4 tag type. Leave Event Parameters and User Properties at their defaults (All), so every parameter passes through unchanged.
For the trigger, click New trigger, then set Trigger Type to Custom and This trigger fires on to Some Events. In the condition row, click the left (variable) dropdown - by default it only lists {{Event Name}} - and choose Choose Built-In Variable.... Client Name is not offered until you do this, so pick it from the built-in variables list. Change the middle (operator) dropdown from contains to equals, and enter GA4 in the value field - this is the name of the default GA4 client in a new server container; open the Clients tab first if you renamed it and use the exact name shown there. Name the trigger All GA4 Client Events and Save.
Do not filter by page_view here: this trigger is deliberately built to match every event the
GA4 client receives - page views, add to cart, purchase.
Save the tag. This forwards every GA4 event through to your GA4 property.
Publish
Click Submit to publish the server container version with the GA4 tag. If you do not need server-side Google Ads conversions (see below), you are done with this chapter.
Optional: Google Ads conversions through your server container
Conversion Linker is only needed together with the Google Ads Conversion Tracking tag - skip both, or add both.
Add a Conversion Linker tag
Add a tag: Tags → New, type Conversion Linker. Its default settings are correct - reuse the same All GA4 Client Events trigger from Sub-step 1. Save. This tag is required for Google Ads conversions: it stores ad click identifiers (gclid) in first-party cookies from the server side.
Add a Google Ads Conversion Tracking tag
First find your Conversion ID and Conversion Label: in Google Ads, go to Goals → Conversions, open your purchase conversion action, and its tag-setup section shows both values. Back in your server container: Tags → New, type Google Ads Conversion Tracking, and enter the Conversion ID and Conversion Label. Value, currency and transaction ID are read automatically from the incoming GA4 purchase event - you do not need to map them manually.
For the trigger, click New trigger, set Trigger Type to Custom and This trigger fires on to Some Events. In the condition row, the variable dropdown already lists {{Event Name}} by default - no built-in variable needs enabling this time - so select it directly. Set the operator to equals and the value to purchase. Name the trigger GA4 Purchase and Save. Publish the container again to include these two tags.
transaction_id - that is same-conversion-action dedup, and it
is safe to run both paths in parallel while you migrate. It does not apply across different conversion
actions: it will not deduplicate this tag against AxiTrace's own Google Ads upload, which is why the warning
above still stands. Keep both the browser-side and this server-side path running until you see server-side
conversions reported in Google Ads, then optionally retire the browser-side path.
Verify with GTM Preview
Back on AxiTrace's Connections page, click Enable debug mode - this spins up a second, cluster-internal-only preview container that GTM Preview sessions are routed to, without affecting your live production traffic. Enabling debug mode can take a few minutes (the next background reconcile tick, plus the preview container's own cold start), which is expected. Once it is ready, open GTM's Preview mode against your server container to inspect requests as they arrive in real time. You should see the GA4 client claiming the incoming requests and your GA4 tag firing (plus Conversion Linker and the Ads tag on purchase events, if you added the optional Google Ads block); GA4 Realtime should then show users within a minute or two.
Optional next step: serve gtm.js from your own domain for better ad-blocker
resilience - see
Serve Google scripts from your own domain.
Serve Google scripts from your own domain (optional, strongly recommended)
By default, the GTM snippet on your site loads gtm.js from
www.googletagmanager.com. Since your server container is already proxying tags on your behalf,
it can proxy the script itself too - serving gtm.js (and the Google scripts it depends on, like
gtag/js) from your own tracking domain instead. AxiTrace's routing on your tracking domain
already forwards these script paths through to your server container, so there is nothing to configure on
the AxiTrace side - everything below happens inside GTM and on your own site.
Of every step in this guide, this is the one that recovers the most blocked measurement - ad-blockers and
tracking-protection lists target googletagmanager.com by name far more aggressively than they
target a domain you own. We recommend every store complete this step once the basic server-side GTM setup
above (Steps 1-9) has been verified working.
Why it matters
-
Ad-blocker and tracking-protection resilience. This is the main win. Many blockers
filter by domain, and
googletagmanager.comis on essentially every filter list, while your own tracking subdomain is on none of them. More successfully loaded tags means more measured sessions and conversions - typically a several-to-low-teens percent recovery. - Full first-party context. The browser sees your own domain family for the script, the hits it sends, and the cookies it sets. Privacy mechanisms in Safari and Firefox treat this far more leniently than a third-party resource.
- End-to-end consistency. Script, hits and forwarding all flow through the same pipeline - a simpler Content-Security-Policy and fewer third-party domains referenced on your site.
gtm.js at all, whereas loading from Google gives you that fallback for free. We
recommend enabling this only once your server-side GTM setup has been stable for a while.
Publish a Web Container client in your server container
In your server container, go to Clients → New and choose the
Google Tag Manager: Web Container client type. Leave Priority at its
default (0). The info line on this screen confirms the client “enables serving Google
scripts (e.g. gtm.js, gtag, etc.) from your tagging server” - there is no separate toggle to also proxy
gtag/js; it comes for free with this client.
Under Allowed Container IDs, add your web container ID (e.g.
GTM-XXXXXXX - the web container that runs on your site, not the server container's own ID).
GTM auto-generates a randomized Tag serving path for that row (e.g. /APZqPlw...)
- leave the generated value as-is unless you deliberately want a new one, in which case use the regenerate
icon next to it. You will need this exact path in Sub-steps 2 and 3. An info banner reminds you to
“Update all in-page code to match the tag serving path for each container ID” - but also that
“your containers will continue to work in the meantime,” so there is no tracking downtime while
you make the switch.
Leave Enable region-specific settings unchecked - you do not need per-region routing here. Click Save, then Submit the container to publish the new client.
Test the endpoint
The Web Container client serves each allowed container ID at two equivalent URLs - pick whichever form you'll use in Sub-step 3, then test it in a browser:
-
Serving path (recommended):
https://axi.yourdomain.com/<tag serving path>/- note the required trailing slash and that nogtm.jsfilename oridparameter is needed. The path alone identifies your container, so this URL carries no ad-blocker-recognizable signature. -
Canonical form:
https://axi.yourdomain.com/gtm.js?id=GTM-XXXXXXX- still defeats domain-based blocking, since it now points at your own domain, but keeps the recognizablegtm.js?id=GTM-string in the path.
Substitute your own tracking domain, your web container ID, and - for the serving-path form - the exact Tag serving path copied from that container ID's row in the Allowed Container IDs table (Sub-step 1). Both return a large JavaScript file on success. An error response means the client is not published yet, the serving path does not match the one shown for that container ID, or the web container ID is missing from the allowed list.
Point your site's GTM snippet at your domain
In your page source, find the GTM snippet installed on your site. The only line you need to change is
j.src= - everything else in the snippet, including the container ID and any
<noscript> GTM iframe block underneath it, stays exactly as it was.
Before - the standard snippet, loading gtm.js from Google's own domain:
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXXX');</script>
<!-- End Google Tag Manager -->
After - the same snippet, served first-party from your tracking domain (serving-path form):
<!-- Google Tag Manager (served first-party via your tracking domain) -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://axi.yourdomain.com/a1B2c3D4e5F6g7h/?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXXX');</script>
<!-- End Google Tag Manager -->
j.src=. axi.yourdomain.com is
your own tracking domain - the one already connected to AxiTrace and shown on your
dashboard, not a literal value to copy. /a1B2c3D4e5F6g7h/ is your own Tag
serving path, copied from your web container ID's row in the Allowed Container IDs table
(Sub-step 1) - the trailing slash is required. GTM-XXXXXXX stays your own web container ID,
unchanged from the original snippet. Every other character in the snippet is untouched.
Canonical alternative: if you tested the canonical form in Sub-step 2 instead, the same
line becomes j.src='https://axi.yourdomain.com/gtm.js?id='+i+dl - only the host changes, and
/gtm.js?id= stays exactly as in the original snippet. This form works just as well; it simply
keeps the recognizable gtm.js?id= signature in the path.
If your page also has a <noscript> GTM iframe fallback (the block Google's install
instructions place right after the opening <body> tag), leave it exactly as it is - only
the <script> block's j.src= line changes.
As GTM's own info banner on the client configuration screen (Sub-step 1) confirms, your containers
“continue to work in the meantime” while you make this change - the old
googletagmanager.com URL keeps serving gtm.js for your container ID throughout the
switch, so there is no tracking downtime during the cutover.
Verify
Reload your site with devtools open. gtm.js should now load from your tracking domain instead
of googletagmanager.com, and your tags should fire exactly as before.
Troubleshooting
Status is stuck on “Deploying”
Give it up to ~15 minutes - this covers a background reconcile tick plus normal infrastructure propagation delay for the routing rule and health checks. If it is still Deploying well past that window, re-check that your tracking domain's routing status is genuinely Live (not pending verification) before contacting support.
Status shows “Failed”
The Connections page shows the specific error under Last error. Fix the underlying issue it describes (most commonly an invalid or stale Container Config value), then click Enable again to retry - retrying after a Failed state is safe and does not create a duplicate deployment.
GTM Preview is not connecting
After turning on debug mode in AxiTrace, wait for the preview container's cold start (typically well under two minutes) before opening GTM Preview. If it still will not connect, confirm debug mode shows as enabled on the Connections page and that you are previewing the correct server container.
Data is not appearing in GA4 (or another destination)
This is almost always a GTM-side configuration issue rather than an AxiTrace one, since AxiTrace's job ends at hosting the container. Check three things first: that the Google tag's Server container URL field (Step 7) points at your AxiTrace tagging server URL, that the GTM Client responsible for receiving that event type is configured and published in your server container, and that you have actually added and published the required GA4 tag (plus the optional Conversion Linker / Google Ads tags, if you need them) described in Configure tags inside your server container - a freshly-provisioned server container has no tags in it by default.
FAQ
Does this replace my existing AxiTrace tracking?
Can I use a different domain for my server container?
What does this cost?
Need Help?
If you have any questions or need assistance:
- Email us at info@axitrace.com - we typically reply within one business day.
- See the Domain Configuration guide if your tracking domain is not yet Live.