← Back to Blog

Server-Side GTM Setup: The Steps, the Costs Google Publishes, and the Parts People Skip

Ihor Odariuk
· updated · 6 min read
Quick answer

Server-side GTM needs a server container in Tag Manager, a tagging server (by default Cloud Run in your own Google Cloud project), a first-party domain for it, and a website Google tag pointed at it. Google estimates about $45 a month per server and recommends at least two, about $90 a month before logging.

Contents · 6 sections

Setting up server-side Google Tag Manager means creating a server container in Tag Manager, running a tagging server for it (Google's default is Cloud Run in your own Google Cloud project), putting that server on your own domain, and pointing your website's Google tag at it. Google estimates about $45 a month per server and recommends at least two. This post walks through the build in order, using Google's documentation. Whether it is worth doing for your business is a separate question, answered in when server-side tagging pays off.

What is server-side tagging, in one paragraph?

In a normal setup, the Tag Manager container runs in the visitor's browser and each tag sends data straight to Google Analytics, Google Ads and anyone else. In a server-side setup, the browser sends one stream of data to a server you control, and the tags run there. Google's introduction to server-side tagging describes it this way: the server runs in your own Google Cloud project or another environment you choose, and "only you have access to the data in the server until you choose to send it elsewhere."

If Tag Manager itself is new to you, start with what Google Tag Manager is. Server-side is a layer on top of a normal web container, not a replacement for it.

What do you need before you start?

From Google's Cloud Run setup guide:

  • A Google Cloud account
  • A Google Cloud billing account
  • The Project Creator and Billing Account User roles

And for the Google Ads part, Google's server-side Ads guide assumes admin rights in both Google Ads and Tag Manager, a working web container, a server container, and the GA4 client set up.

The setup steps in order

Step What you do Where
1 Create a server container Tag Manager
2 Provision a preview server and a tagging server Tag Manager (automatic) or Google Cloud (manual)
3 Put the tagging server on your own domain DNS, or your CDN or load balancer
4 Point the website's Google tag at the server Web container, or gtag.js
5 Check that the GA4 client claims the requests Server container
6 Add server tags (GA4, Google Ads) and triggers Server container
7 Preview, then publish Both containers
8 Remove the duplicate web tags Web container

Step 2: provisioning the servers

Google's guide says you can provision the Cloud Run service "either automatically in Google Tag Manager or manually in Google Cloud." You get two services: a preview server, which enables the preview feature for the container, and a tagging server, which handles live traffic.

Step 3: the domain

When a tagging server is first created, it sits on a domain supplied by the cloud provider. Google's custom domain guide compares the three options:

Option Example Server-set cookies Setup
Same origin (Google's best practice) www.example.com/metrics Full access to the security and durability benefits CDN or load balancer forwards requests, may need DNS changes
Subdomain metrics.example.com Full access DNS changes
Default domain metrics.run.app None, JavaScript cookies only Pre-configured

On the default domain the server cannot set cookies at all; Google's table says it "can only set Javascript cookies." Google's intro "strongly" recommends installing the server on your first-party domain and switching it to production mode before sending any production traffic.

Step 4: sending data from the website

With gtag.js, the change is one option. Google's example adds server_container_url to the config command:

gtag('config', 'TAG_ID', {
  server_container_url: 'https://analytics.example.com',
});

With Tag Manager, the Google tag in your web container is pointed at the tagging server; Google's guide on sending data to a server container covers both options. That guide also lists content security policy entries you need if your site has a strict policy: the server container URL in img-src, connect-src and frame-src, and no X-Frame-Options rule that blocks iframes from it.

Step 5: the client

A server container needs a "client" to accept each incoming request and turn it into events. Google's intro says server containers come with two clients included, Google Analytics and Measurement Protocol, so for a standard GA4 setup there is nothing to build here. You check in preview that the requests are claimed.

Step 6: Google Ads conversions on the server

Google's server-side Ads setup has three steps:

  1. Add a Conversion Linker tag in the server container. Google says the All pages trigger is the best option in most cases.
  2. Set up the key event: mark it in GA4 (Admin, Key events), and send it from the web container with a GA4 Event tag.
  3. Add a Google Ads Conversion Tracking tag in the server container with your conversion ID and label, triggered by a custom event whose name matches the GA4 event.

Enhanced conversions are an optional fourth step. One detail from Google's guide that breaks quietly if missed: when you pass user-provided data on an event tag, the parameter name must be user_data, so the hashed data reaches the server container.

Steps 7 and 8: test, publish, remove duplicates

In the server container, click Preview, browse your site, and check the Tags tab for what fired and the Console tab for transmission errors. Google's own last step is easy to skip: once the server tag works, remove the equivalent Google Ads conversion tag from the web container "to avoid data duplication." Until you do, every conversion can be sent twice, once from the browser and once from the server.

What does server-side GTM cost to run?

These are Google's own figures from the Cloud Run guide:

Item What Google says
One server About $45 a month, 1 vCPU and 0.5 GB memory, CPU always allocated
Recommended minimum 2 instances, "to reduce the risk of data loss in case of a server outage"
Capacity Autoscaling 2 to 10 servers is expected to handle 35 to 350 requests per second, depending on tags
Worst case The max-instances setting is the most you can pay for; Cloud Run only adds instances when needed
Logging Every request is logged by default; above roughly 1 million requests a month this "may incur significant logging charges," and Google recommends disabling request logging

So the floor at Google's recommended two instances is about $90 a month before logging. Google also suggests setting a billing alert and using the Google Cloud Pricing Calculator, which opens with a default server-side tagging estimate.

What do people skip after launch?

Server updates. Google says new tagging server releases contain security fixes and recommends updating "at least" for each major version, by deploying a new revision with the container image gcr.io/cloud-tagging-10302018/gtm-cloud-image:stable. Tag Manager may keep showing the update message for up to a day afterwards; the preview page shows the current version.

Old App Engine deployments. If you set up server-side tagging on App Engine before and moved to Cloud Run, Google says to disable the App Engine application once it gets no traffic, to avoid unexpected billing.

The web tags. Duplicate conversion tags left in the web container, mentioned above.

Testing with a real conversion. Preview shows that a tag fired. It does not show that the conversion arrived in Google Ads with the right value and counted once. After any change I send one real test lead and check that it arrived with its source, the habit described in offline conversion tracking.

Put the tagging server on your own domain before real traffic

If you decide to build it, follow the order above, put the server on your own domain before real traffic, and remove the duplicate web tags the same day the server tags go live. Budget for two servers and turn off request logging if traffic is high.

How I set up conversion tracking for service businesses, with or without a server container, is on Google Ads conversion tracking. If you want the server-side build done for you, that is server-side tagging setup. Fixed prices are on pricing, and the free written diagnostic is the place to start.

Related:

The package for this
Google Ads conversion tracking setupfrom $399

One clean Google Tag Manager container, GA4 key events for form fills and phone clicks, Google Ads conversions where only real leads drive bidding, and calls tracked by channel.