Server-Side GTM for GA4: What It Is, Why Use It and How to Set It Up
By Jason Dolan · · 10 min read
In short: Server-side Google Tag Manager (server-side GTM, or sGTM) moves part of your tracking from the visitor’s browser to a server you control. For GA4 users that means better control over what data is sent, more durable first-party cookies, fewer scripts on your pages, and a stronger privacy position. It also means more setup, a running cost and a bit of engineering. This guide explains what it is, why you might use it, how to set it up for GA4 and where it fits with Parallel Tracking. It draws on Google’s documentation and the other sources listed at the end.
What is server-side GTM?
With a normal (“client-side”) setup, your website loads a GTM container in the browser. That container fires tags, and each tag sends data straight from the visitor’s browser to vendors such as Google Analytics, Google Ads and Meta.
Google’s overview describes server-side tagging as moving measurement tag instrumentation from the website or app to a server-side processing container, hosted on Google Cloud or another platform of your choice. In practice there are two containers:
- A web container in the browser, which collects events and sends one stream of data to your own server.
- A server container running on a server you control. It receives that stream through a “client” (an adapter that claims an incoming request and turns it into events), can clean and enrich the events, and then forwards them to GA4 and other vendors through server-side tags.
Think of it as a checkpoint between your website and your vendors. Nothing leaves your setup without passing through it.
Browser (web container) --> your server container (first-party domain) --> GA4, Google Ads, other vendors
Why use server-side GTM?
Google itself names two benefits: better performance, because fewer measurement tags run in the browser, and better security, because visitor data is collected and distributed in an environment you manage. The independent guides add several more.
More control over your data
Because every request passes through your server, you decide exactly what gets sent. You can remove personal data such as IP addresses or email addresses, rename or transform events, add data the browser does not have (for example, margin from your backend), and keep API keys on the server. Google’s documentation also describes transformations that can strip parameters before tags forward them.
More durable first-party cookies
If your server runs on your own domain, it can read and write cookies that page scripts cannot see (HttpOnly cookies), which Google says improves cookie privacy and durability. Google’s custom domain page is specific about this: a server on the same origin as your site (for example example.com/metrics, which Google calls best practice) or on a subdomain (metrics.example.com) gets full access to server-set cookies, while the default run.app address does not. Hosting vendor Stape claims cookie lifetimes of up to 400 days with a custom domain, but that is a vendor claim and browsers change their rules, so test it on your own site.
Faster pages
Instead of loading a separate script and firing a separate request for each vendor in the browser, the page sends one request. That can mean less JavaScript and a lighter page, especially on sites with many marketing tags. Some vendors quote specific speed gains, but they rarely explain how they measured them.
Fewer blocked requests, with caveats
Requests go to your own domain instead of third-party domains, so some blockers will miss them. Be realistic, though. iubenda’s guide says sGTM “doesn’t reliably get around ad blockers” and tells readers to measure the effect and not assume it.
Privacy and compliance
You see and control all outgoing data, and it is easier to show an auditor what is shared with whom. Server-side tagging does not remove the need for consent. iubenda explains that consent state, set up in the web container, travels with each event. Google tags in the server container are consent-aware, but non-Google tags only respect consent if you configure them to, usually with trigger conditions. Under the EU’s ePrivacy rules, reading or storing information on a device generally needs consent whichever way the data is routed afterwards. Google also notes that the owner of the server environment may have access to your data, so check your hosting provider’s terms.
A foundation for more than GA4
Once the server container is in place, you can use it for Google Ads conversions, Meta’s Conversions API, TikTok, Pinterest and more, and for sending data to your own warehouse.
The downsides, honestly
- Cost. The container is free, but hosting is not. Google’s Cloud Run setup guide estimates about $45 per server per month, and recommends at least two instances to reduce the risk of data loss if a server fails. Its overview page recommends three, and expects roughly $30 to $50 per server per month once you move past the free test setup. iubenda turns Google’s figures into “roughly $90 a month” for a production setup of two servers. Large traffic volumes cost more, and request logging can add charges beyond about a million requests a month unless you filter it. Simo Ahava also points out that Cloud Run costs are harder to predict than the older App Engine, because it bills per request processed. Managed hosts such as Stape sell hosting too, and claim to be cheaper, but treat vendor price comparisons with care.
- Complexity. You maintain a custom domain, DNS records, two containers and a debugging process. Mistakes can silently break tracking.
- Maintenance. Google recommends updating the tagging server image regularly, especially for major versions.
- It is not a magic fix. It does not give you consent, it does not make blocked users visible, and it does not remove GA4’s own limits.
Why it matters for GA4 users
GA4 works well with server-side GTM. Google recommends sending data from the web page with a Google tag, and the GA4 client is pre-installed in the server container. It claims the incoming GA4 requests and turns them into events, and a GA4 tag forwards them to Google Analytics. Practical benefits for GA4:
- Cleaner data in GA4: filter out internal traffic and bots, normalise campaign parameters and remove personal data before it is stored.
- More complete data where requests would otherwise be blocked, and longer-lived first-party identifiers.
- Enrichment: add product margin, customer type or other backend data to events.
- Better conversion signals for Google Ads, sent from the server.
How to set up server-side GTM for GA4
The exact screens change over time, so treat these steps as a guide and check Google’s current documentation. Before you start, you need a working GA4 property, a GTM web container and a Google Cloud account with billing enabled (or an account with a hosting provider).
- Create a server container. In Google Tag Manager, open your account menu, choose Create Container and set the target platform to Server.
- Provision the tagging server. Google recommends automatic provisioning: Tag Manager creates a new Google Cloud project and a Cloud Run tagging server for you. To use an existing project, follow the Cloud Run setup guide, and for other infrastructure there is a manual guide using Google’s Docker image. Be aware that the default deployment has restricted resources and is meant for testing with limited traffic only. Before live traffic arrives, increase the number of instances.
- Set up a custom domain. Map a subdomain of your site (for example
data.example.com), or serve the server from a path on your own domain through a CDN or load balancer, so requests are first-party and the server can set cookies. Google strongly recommends this over the defaultrun.appaddress. - Tell GTM the server URL. In the server container, go to Admin, then Container Settings, click Add URL, paste your server URL and save.
- Point your GA4 tag at the server. In the web container, edit your Google tag and set its server container URL to your new domain. From now on, GA4 events go to your server first. If your site uses a Content Security Policy, allow the server URL in
img-src,connect-srcandframe-src, as Google’s send data page describes. - Check the GA4 client. The server container includes a GA4 client by default. Check its priority and activation settings if you run more than one client.
- Add a GA4 tag in the server container. Create a GA4 tag with your measurement ID, triggered by events from the GA4 client. This forwards the data to Google Analytics.
- Test. Click Preview in the server container. If the preview page loads, the server is set up correctly. You can also open your server URL with
/healthyat the end and look for the text “ok”. Use preview mode in both containers to confirm that requests reach your domain, the client claims them and the GA4 tag fires with the right parameters. - Verify in GA4. Open DebugView and the real-time reports and confirm events arrive once, not twice.
- Publish and monitor. Publish both containers, set a billing alert in Google Cloud, and compare event volumes with your old setup for a few weeks.
- Add other tags. Once GA4 is stable, move Google Ads, Meta and other vendors to the server, one at a time.
Common mistakes
- Sending events twice. Leaving the old client-side GA4 tag active next to the new server-side route doubles your data. Make sure only one path remains.
- Staying on the default domain. It prevents server-set cookies, which removes one of the main benefits.
- Too few instances in production. A single small server risks dropped data during outages or spikes.
- Forgetting consent. Pass consent state to the server and respect it in your tags.
- Not monitoring. Set up alerts for failed requests and watch your cloud costs.
Server-side GTM and Parallel Tracking
If you already use Parallel Tracking, or plan to, nothing changes. A GA4 implementation delivered through server-side GTM still supports Parallel Tracking, just like any other GA4 implementation method (a gtag.js setup, a web GTM container or a custom integration). You keep the benefits of your server-side setup, and Parallel Tracking adds complete, unsampled data in your warehouse without the 1 million event BigQuery export cap, with near-real-time processed data and an optional EU-only pipeline.
Server-side GTM or Google Tag Gateway?
Google also offers Google Tag Gateway, a simpler way to send Google tags through your own domain with a CDN. It is easier and free, but it does less: it focuses on Google tags, keeps tag execution in the browser and gives you no data transformation. Choose server-side GTM if you want control, enrichment, privacy filtering and non-Google vendors. Choose the gateway if you want a quick, light improvement for a Google-only setup. Independent sources, including Analytics Mania, say the gateway does not replace server-side GTM, and that the two can be combined.
FAQ
Do I need server-side GTM for GA4?
No. GA4 works without it. It becomes worthwhile when you need more control over data, you run many marketing tags, ad blockers cost you significant data, or privacy requirements demand it. iubenda suggests it pays off mainly for sites with meaningful ad spend, and may not justify itself for small sites.
How much does server-side GTM cost?
Google estimates about $45 per server per month on Cloud Run, with at least two servers recommended for production, plus traffic and logging costs. Estimate it with the Google Cloud Pricing Calculator, which Google’s guide says opens with a default server-side tagging estimate.
Does it bypass consent?
No. You are still responsible for collecting consent and honouring it, and it should be part of the design from the start.
Can I use it with Parallel Tracking?
Yes. Parallel Tracking works with a GA4 implementation delivered through server-side GTM, just like with any other implementation.
Need help with server-side GTM?
Reflective Data can set up server-side GTM for you: the server container, the custom domain, the GA4 client and tags, consent handling, testing and monitoring. We also consult on every other GA4 topic, from Google Tag Manager and GA4 implementation and audits to BigQuery and attribution. Book a free consultation.
Sources
- Google, Server-side tagging overview (developer documentation).
- Google, Set up server-side tagging with Cloud Run.
- Google, Manual setup guide.
- Google, Send data to server-side Tag Manager.
- Google, Custom domain configuration.
- Simo Ahava, Cloud Run with server-side tagging in Google Tag Manager (October 2023). An independent expert’s walkthrough. Some steps are outdated, so use it for background only.
- iubenda, Google Tag Manager server-side tracking: how it works and how to set it up (updated October 2026). Vendor content: iubenda sells consent and server-side tracking products.
- Stape, Server-side tracking benefits (updated September 2026). Vendor content: Stape sells sGTM hosting, and its case-study figures are vendor-selected.
- Analytics Mania, Google Tag Gateway, for the comparison with the gateway.
Google changes these guides often, and its own pages differ slightly on instance counts and costs. Check the current documentation before you deploy.
written by
Jason Dolan
Jason is an expert in digital analytics, data pipelines and data warehouses. Since 2009, he has helped numerous companies become more data-driven and gain full control over their data flows.
We love AI, but this article was written by one of our experts.
discussion
0 comments