On this page
Server-side tagging in Google Tag Manager means your website sends measurement data to your own tagging server first, and a server container then forwards it to GA4, Google Ads and other platforms. Setup takes five parts: a server container, hosting, a first-party subdomain, routing the web Google tag to it, and moving tags into the server container one at a time.
What You Need Before You Start
- A working web GTM container with GA4 already tracking (see our GTM setup guide).
- Admin access to GTM, so you can create a second (server) container.
- A Google Cloud account with a billing account, or an account with a managed server GTM host.
- Access to your domain’s DNS settings to add a subdomain such as metrics.example.com.
- Your developer’s help if the site uses a Content-Security-Policy.
- A budget for hosting and a billing alert. Server-side tagging is not free once traffic grows.
If you’re still deciding whether to do this at all, read is server-side tracking worth it for your business first. This guide assumes you’ve decided to go ahead.
How Does Server-Side Tagging Work?
The browser sends one stream of data to your tagging server, and the server container decides what to forward to each platform. Google calls the parts that receive requests “clients”: they turn incoming requests into events that your server tags then send on.
Google lists a few reasons to do this. Fewer tags on the page means less code running in the visitor’s browser. The data passes through a server environment you manage, so you control what each platform receives. And a tagging server on your own subdomain can set HttpOnly cookies that page scripts can’t read.
For a plain-English version without the setup detail, see what is server-side tracking.
Do You Still Need a Web GTM Container With Server-Side GTM?
Yes, for most websites. The web container still collects clicks, page views and ecommerce events in the browser; it just sends them to your server instead of to Google, Meta and others directly.
| Container | Runs in | Job |
| Web container | Visitor’s browser | Collects events, sends them to your server |
| Server container | Your tagging server | Receives events, forwards them to platforms |
Some platforms can also receive events straight from your store or CRM server, but that’s a separate setup from this guide.
How Do You Set Up Server-Side GTM Step by Step?
Work in this order and test after each step. Most problems come from skipping the custom domain or moving every tag at once.
Step 1: Create a Server Container
In Google Tag Manager, create a new container in the same account and choose Server as the container type. GTM shows a Container Config string; you’ll need it if you host the server yourself.
Step 2: Deploy the Tagging Server
Google recommends Cloud Run. Its setup guide offers automatic provisioning from inside Tag Manager or manual setup in Google Cloud, and needs a Google Cloud billing account plus the right project and billing roles.
- Deploy two services: a preview server for GTM’s preview mode and a tagging server for live traffic.
- Google recommends a minimum of 2 instances so an outage doesn’t lose data.
- Google estimates autoscaling between 2 and 10 servers handles about 35 to 350 requests per second, depending on your tags.
- Set a billing alert in Google Cloud as soon as the project exists.
If you use a managed host instead, it asks for the same Container Config string and gives you a server URL.
Step 3: Add a First-Party Subdomain
Point a subdomain such as metrics.example.com at your tagging server, or serve it from a path on your own site. Google’s custom domain guide calls the same-origin path the best practice and says the default cloud domain can only set JavaScript cookies, not server-set ones.
| Option | Example | Setup |
| Subdomain | metrics.example.com | Add a DNS record |
| Same origin | www.example.com/metrics | CDN or load balancer rule |
| Default domain | …run.app | None, but no server-set cookies |
Google also strongly recommends a first-party domain and production mode before you send live traffic.
Step 4: Register the Server URL in GTM
In the server container, open Admin > Container Settings, select Add URL, paste your server URL and save. Then check the server is up by adding /healthy to the URL; Google’s guide says it should return ok.
https://metrics.example.com/healthy → okStep 5: Route the Web Google Tag to Your Server
In the web container, create a variable of type Google tag: Configuration settings with one parameter, then select it in your Google tag.
Variable type: Google tag: Configuration settings
Variable name: Server URL
Parameter: server_container_url = https://metrics.example.com- Open your Google tag (or GA4 destination tag) in the web container.
- Under Configuration settings, select the Server URL variable.
- Keep it on the Initialization – All Pages trigger so it fires before other tags.
- Save, but don’t publish yet; test first.
If your site sends a Content-Security-Policy header, Google says it must allow your server URL for img-src and connect-src, and frame-src if you use the service worker option. Otherwise the browser blocks the requests.
Step 6: Set Up GA4 in the Server Container
The server container comes with a Google Analytics client already installed. Add a GA4 tag in the server container that fires on events that client claims, so GA4 receives the data from your server.
Step 7: Test Both Containers, Then Publish
Open Preview in the server container and Preview in the web container, then browse the site. You should see GA4 requests arrive at the server, claimed by the Google Analytics client, and your GA4 tag fire.
In the browser’s Network tab, GA4 requests should now go to your subdomain rather than Google’s domain.
Publish the server container first, then the web container, and check GA4 Realtime.
Should You Host on Google Cloud Run or a Managed Host?
Choose Cloud Run if you have someone comfortable with Google Cloud billing and monitoring. Choose a managed server GTM host if you want setup, scaling and updates handled for a monthly fee.
| Factor | Google Cloud Run | Managed host |
| Setup effort | Higher | Lower |
| Billing | Google Cloud usage | Host’s plan |
| Scaling and updates | You manage | Host manages |
| Control | Full | Within host’s options |
Google’s Cloud Run guide estimates about $45 per server per month (1 vCPU, 0.5 GB memory, CPU always allocated), as of October 2026. With the 2-instance minimum, that’s the floor before traffic-based costs.
We break down the full numbers, including managed hosting plans, in how much server-side tracking costs.
How Do You Move Google Ads and Meta to the Server Without Double Counting?
Move one platform at a time: add its server tag, test it, then remove or change its browser tag in the same release. Running the browser tag and the server tag for the same conversion without deduplication counts it twice.
- GA4: once the Google tag routes through your server, keep a single GA4 tag in the server container.
- Google Ads: add the Google Ads conversion and Conversion Linker tags in the server container, test, then remove the web versions.
- Meta: if you keep the browser Pixel alongside the server Conversions API, both events need the same event ID so Meta can deduplicate; see our Meta Conversions API setup guide.
Examples by business type: an online store usually moves GA4 and Google Ads purchases first; a lead-gen company moves form conversions and passes them on to Google Ads; a SaaS company often starts with GA4 sign-ups and trial starts.
Server-side tagging still has to respect consent. Your server container only receives what the browser sends, so set up consent in the web container first; our Consent Mode v2 guide covers that.
Troubleshooting Server-Side GTM
| Problem | Likely cause | Fix |
| No requests reach the server | server_container_url missing or not published | Check the variable and Google tag; publish |
| Requests blocked in the browser | Content-Security-Policy | Allow the server URL in img-src and connect-src |
| /healthy doesn’t return ok | Server not deployed or DNS not pointing | Check hosting and DNS |
| GA4 data doubled | Web GA4 tags still sending directly | Keep one route per destination |
| Conversions missing after move | Server tag not firing on claimed events | Check server Preview triggers |
| Errors during traffic spikes | Too few instances | Raise minimum and maximum instances |
| Cookies not lasting | Using the default run.app domain | Use a subdomain or same-origin path |
Running Shopify? The checkout has its own rules; see how to set up server-side tracking on Shopify.
When Should You Get Help With Server-Side Tagging?
Get help when ad platforms optimize on numbers you don’t trust, when you’re moving several platforms at once, or when nobody on the team wants to own a cloud server. Our Tracking & Analytics service plans, builds and maintains server-side setups month-to-month with no lock-in, starting with a free audit.
FAQ
Frequently asked questions
Is Server-Side GTM Overkill for a Small Business?
It can be. If you run little paid traffic and only need basic GA4 reports, a clean browser setup is usually enough. Server-side tagging pays off when ad spend is meaningful, when several platforms need the same conversion data, or when you want more control over what each platform receives.
Will Server-Side Tagging Recover Purchases Blocked by Ad Blockers and Safari?
It can help some, especially with a first-party subdomain, but it is not a guarantee. The browser still has to send the event to your server, and some blockers and privacy settings stop that too. Treat it as an improvement in data quality, not a way around visitor choices.
How Much Does Server-Side GTM Cost per Month?
On Google Cloud Run, Google estimates about 45 US dollars per server per month for its standard configuration, as of October 2026, and recommends at least two instances for live traffic. Managed hosts charge their own monthly plans, and higher traffic raises costs on either option.
Can I Still Send Data Through Server-Side GTM if a Visitor Rejects Cookies?
The server container only works with what the browser sends, and consent settings in the web container decide that. Set up Consent Mode in the web container so tags behave according to each visitor's choice, and make sure server tags respect the consent state passed with each event.
Why Are My GA4 or Google Ads Conversions Missing or Doubled After Moving to Server-Side?
Missing conversions usually mean the server tag isn't firing on the events the client claims. Doubled conversions usually mean the old browser tag is still sending to the same destination. Check both containers in Preview and keep one route per destination.
Does Server-Side Tagging Improve ROAS?
Not by itself. It can give ad platforms more complete and consistent conversion data, which helps their bidding, but campaign results still depend on targeting, offers and landing pages. Measure conversion counts against your own sales data before and after the change.
5 sources & references
- Google for Developers An introduction to server-side tagging developers.google.com
- Google for Developers Server-side tagging (overview) developers.google.com
- Google for Developers Set up server-side tagging with Cloud Run developers.google.com
- Google for Developers Custom domain configuration developers.google.com
- Google for Developers Send data to server-side Tag Manager developers.google.com
Official pages we checked when writing this article.






