Server-side GTM: what it is, what it costs to run, and the same result without a server container
Server-side Google Tag Manager (sGTM) runs a GTM server container on a server you control instead of in the visitor's browser. Google recommends Cloud Run in your own Google Cloud project, at about $45 a month per server with at least 2; hosts such as Stape and Addingwell run it for you, with free tiers (as of 7 November 2026). AgentFirstStack Tags gets the same result without a server container: conversions go server to server to the ad platforms, collected on your own subdomain, and an AI agent sets it up. Server-side GTM fits better if your team builds tracking in GTM or needs vendors only its templates reach.
Set it up with one prompt
Paste this into your coding agent. It maps what your web and server containers do before it changes anything, and leaves them running until you say so.
Move this project's server-side Google Tag Manager setup to AgentFirstStack Tags, which sends conversions to the ad platforms' APIs itself, with no server container to host. It's free, open-source and built for agents, and you can do the setup yourself: there is no signup form. 1. Read https://agentfirststack.com/llms.txt and https://tags.agentfirststack.com/llms.txt. 2. If this project's .env already has AGENTFIRSTSTACK_API_KEY, use it and read AGENTFIRSTSTACK.md. Otherwise get a key: curl -X POST https://agentfirststack.com/v1/signup, and save api_key in .env as AGENTFIRSTSTACK_API_KEY and in the production secrets. 3. Find out how the site uses GTM today: the web container id (GTM-...), whether its Google tag sends to a server container (server_container_url, or a tagging subdomain of our domain), and which platforms the server container's tags send to. Use the Tag Manager API or Google's Tag Manager MCP server if you have access; otherwise ask me for both exports (GTM Admin > Export Container). Tell me what you found before you change anything. 4. Create a tags container for the production domain, run scan, and import the web container (draft/import with format "gtm", dry run first). List what didn't map. 5. Serve the container from our own domain: a first-party domain (POST https://agentfirststack.com/v1/first-party-domains with a neutral subdomain such as edge.<our domain>; add the one CNAME it returns if you can change our DNS, otherwise give me the record), or meanwhile the path proxy from GET /v1/containers/:id/install?proxy=1 with its proxy key kept server-side. 6. Replace the server container's work with destinations: run setup with the platforms its tags send to, analytics, and the conversions that matter here (purchases, leads, sign-ups). Ask me for exactly the IDs and tokens setup reports as missing, and where I find each. 7. Validate, test every destination and show me each platform's answer, open a preview and read its log, then publish. Keep GTM and the server container running until the event log shows the same conversions arriving. When I say so, remove GTM's snippet in the same change that publishes, so nothing counts twice. 8. Write the container id and the env var name (never the key) in AGENTFIRSTSTACK.md, and create a claim link for me with POST https://agentfirststack.com/v1/claim-link. Tell me what you set up, what each test returned, what didn't map from GTM, what's waiting on me, and give me the claim link.
What server-side GTM is
A web container runs in the page and sends data to each vendor from the visitor's browser. A server container, Google's intro says, "doesn't run in the user's browser or on their phone": it "runs on a server that you control", in your own Google Cloud project "or in a different environment of your choosing" (An introduction to server-side tagging, as of 7 Nov 2026).
It keeps GTM's tags, triggers and variables and adds clients: adapters that receive a request, turn it into events and run the container's tags on them. Server containers come with a Google Analytics 4 client and tag. Your site sends to it by pointing the Google tag at the server container's URL with server_container_url, so a tag on the page still does the collecting; the server container decides where each event goes from there.
Before production traffic, Google strongly recommends serving it from your first-party domain and switching the server to production mode. Its custom domain guide offers the same origin (www.example.com/metrics) or a subdomain (metrics.example.com); on the cloud provider's default domain the server gets "None" of the server-set cookie benefits and "can only set Javascript cookies" (Custom domain configuration).
Where to host it
| Option | Who runs it | Cost and sizing, as of 7 Nov 2026 |
|---|---|---|
| Cloud Run | You, in your Google Cloud project; GTM can provision it for you | About $45 a month per server (1 vCPU, 0.5 GB memory, CPU always allocated); Google recommends at least 2, and expects 2 to 10 servers to handle 35 to 350 requests a second |
| App Engine | You, in your Google Cloud project | About $40 a month per production server, at least 3 recommended; a test setup on an F1 instance costs nothing "in most cases". Google's note: "The recommended deployment option is Cloud Run." |
| Any other environment | You | The tagging server is "a Node.js server inside of a Docker image"; you run a tagging cluster and a separate preview server, at your host's prices |
| Stape | Stape | Free up to 10K requests a month, then $17 a month billed annually ($20 monthly) for 500K; plans and features in our Stape alternative page |
| Addingwell | Addingwell | A free plan up to 100,000 requests, then 90 euros a month for 1 million requests plus 2.30 euros per extra 100k |
On any host, Google's manual setup guide notes that the owner of the server environment "may have access to your data".
What it costs to run
- The servers. At Google's figures, the recommended 2 Cloud Run servers are about $90 a month. Cloud Run scales up with load, and the max-instances setting is "the worst case scenario for how much you will need to pay"; Google suggests a billing alert.
- Logging. Every request is logged by default, and past about 1 million requests a month "those log messages may incur significant logging charges", so Google recommends turning request logging off.
- Regions. Serving several regions means a tagging server in each and a load balancer in front.
- Updates. Google recommends updating the tagging server at least for each major version, by deploying a new revision.
- The work. Someone builds and maintains the server container: its clients, a tag per vendor, often from a template gallery, the custom domain, and the web container's settings that send to it.
How AgentFirstStack gets the same result
AgentFirstStack Tags has no server container. The service that receives your conversions is also what calls the ad platforms, so there's nothing in between for you to host, scale, log or update.
- One snippet loads the container. You define each conversion once, in plain terms through
setupor in the config: a dataLayer event, a thank-you page, a form. - The browser runtime fires the pixels with one
event_idand posts the conversion to/collect, on your own subdomain when it's served first-party. - The service calls each platform's API with your credentials and the same
event_id, retries failures, and logs each platform's answer for 7 days. - Your backend reports what the browser can't see with
POST /v1/containers/:id/events, joined to the visitor's stored click ids.
Hosting is ours, free within fair-use limits, or yours on Cloudflare Workers if you self-host. The full feature list is on the conversion tracking page.
Side by side
| Server-side GTM | AgentFirstStack Tags | |
|---|---|---|
| What runs on a server | Your GTM server container, on a server you host or rent | The service itself; no container to host |
| What you build | Clients and a tag per vendor in GTM, plus the web container's link to it | Conversions described once; setup writes and validates the config |
| Platforms | Any vendor with a server template, or your own | GA4, Google Ads, Meta, TikTok, LinkedIn, Pinterest, Reddit, Snap, X, analytics, webhooks |
| Counted once | Your web and server tags must carry the same event id | One event_id per conversion, used by the pixel and the API |
| Your own domain | Same origin or a subdomain, mapped to your server | A first-party domain (one CNAME to fp.agentfirststack.com) or a path proxy |
| Server-set cookies | Yes, from the same origin or a subdomain | Only through the path proxy, where page and collector share one host; through a first-party domain, the script sets them |
| Shaping data | Transformations that share, change or exclude event parameters for tags | Per-destination rules: parameters in or out, conditions, page URLs without query strings, lookup tables |
| Testing | GTM's preview mode | A preview log of which tags fired and why not, and each platform's test mode |
| Running costs | Servers, logging and updates, or a host's plan | Free hosted service with fair-use limits; AGPL-3.0, self-hostable |
When to choose which
Use server-side GTM if
- Your team builds tracking in Google Tag Manager and wants the server side in the same tool.
- You need vendors only GTM's server templates reach, such as affiliate networks and email or CRM tools, or your own clients for other data streams.
- The data has to pass only through servers you run, in your own Google Cloud project or another environment.
- You want first-party cookies set by a server on your own subdomain.
Use AgentFirstStack Tags if
- You want conversions sent server-side to the main ad platforms without building, hosting or paying for a server container.
- An agent should set it up and keep it working: test each platform in its test mode, publish and read the delivery log, all over the API.
- Conversions only your backend knows should credit the ad click that started them.
- You want it free and open source.
Weighing a host rather than Google Cloud? The Stape alternative page compares Stape's plans with AgentFirstStack in detail.
Moving from server-side GTM
POST /v1/containers/:id/draft/import with format: "gtm" takes the web container's export or the Tag Manager API's lists, with a dry run first. Google tag and GA4, Google Ads, custom HTML and image tags, the Meta, TikTok, LinkedIn, Pinterest, Reddit, Snap, X and UET templates and nearly every trigger and variable map. Server-container clients don't: the server side becomes destinations, which need each platform's credentials. GTM has no conversions, so add them, and the pixels and APIs share one event id.
Keep the server container running until the delivery log shows the same conversions arriving. Then remove GTM's snippet in the same change that publishes the container, or conversions count twice, and shut down the tagging and preview servers or the host's plan.
FAQ
What is server-side GTM?
Server-side Google Tag Manager runs a GTM server container on a server you control instead of in the visitor's browser. The site sends its measurement requests to that server; clients in the container turn them into events, and the container's tags send them on to Google Analytics, ad platforms and other vendors.
How much does server-side GTM cost to run?
As of 7 November 2026, Google puts each Cloud Run server at about $45 a month and recommends at least 2, so about $90 a month before traffic grows, plus logging charges at high volume. On App Engine it's about $40 a month per production server, with at least 3 recommended. Hosts charge by requests: Stape is free to 10K a month, then $17 a month billed annually; Addingwell is free up to 100,000 requests, then 90 euros a month for 1 million.
Do I still need a web container with server-side GTM?
Something on the page still has to send the data. Google's setup points the Google tag (gtag.js, or the Google tag in a web container) at the server container's URL with server_container_url. The server container then decides where each event goes.
Can AgentFirstStack import my server-side GTM container?
Only the web container. draft/import maps a web GTM container's tags, triggers and variables, with a dry run first; server-container clients aren't imported. The server side becomes destinations, which take each platform's credentials.
Does AgentFirstStack serve tracking from my own domain?
Yes. A first-party domain is one CNAME from a subdomain such as edge.example.com to fp.agentfirststack.com, created with POST https://agentfirststack.com/v1/first-party-domains; tags then load and collect at /_t/ on it, with no server code. A path proxy on your own server is the other way. Only the path proxy also sets the container's cookies from the server; through a first-party domain, its script sets them.
Related
- Conversion trackingNine ad platforms, browser and server, one event id.
- Stape alternativeConversion APIs without hosting a GTM server container.
- Conversions API Gateway alternativeMeta and eight more platforms, nothing to host.
- Server-side conversion trackingHow each platform counts a conversion once.
- Google Tag Manager MCP comparedEdit GTM, or let the agent run the tag manager.
- Google Ads conversion trackingBrowser tag and server upload, tested before it counts.