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.

ContainerRuns inJob
Web containerVisitor’s browserCollects events, sends them to your server
Server containerYour tagging serverReceives 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.

OptionExampleSetup
Subdomainmetrics.example.comAdd a DNS record
Same originwww.example.com/metricsCDN or load balancer rule
Default domain…run.appNone, 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 → ok

Step 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
  1. Open your Google tag (or GA4 destination tag) in the web container.
  2. Under Configuration settings, select the Server URL variable.
  3. Keep it on the Initialization – All Pages trigger so it fires before other tags.
  4. 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.

FactorGoogle Cloud RunManaged host
Setup effortHigherLower
BillingGoogle Cloud usageHost’s plan
Scaling and updatesYou manageHost manages
ControlFullWithin 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

ProblemLikely causeFix
No requests reach the serverserver_container_url missing or not publishedCheck the variable and Google tag; publish
Requests blocked in the browserContent-Security-PolicyAllow the server URL in img-src and connect-src
/healthy doesn’t return okServer not deployed or DNS not pointingCheck hosting and DNS
GA4 data doubledWeb GA4 tags still sending directlyKeep one route per destination
Conversions missing after moveServer tag not firing on claimed eventsCheck server Preview triggers
Errors during traffic spikesToo few instancesRaise minimum and maximum instances
Cookies not lastingUsing the default run.app domainUse 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.