To set up server-side Google Tag Manager for a client, you create a server container in GTM, host it in the client's own cloud or hosting account, serve it from the client's domain, point the web GA4 tag at it, and then send events on to GA4, Google Ads and Meta from the server. The build is usually a day of work. Getting it right means deduplicating with the browser tags that still run, testing every conversion in server preview, and leaving behind monitoring and documentation so the container does not become a black box.
This guide is written for agency teams who already run web GTM containers for clients and are moving one or more accounts to server-side tagging. If you are still deciding whether a client needs it at all, read is server-side tracking worth it first. A server container adds a hosting bill and a piece of infrastructure someone has to own, and not every account earns that back.
Before you start: what you need from the client
Server-side tagging touches more systems than a web container does. Collect access and decisions up front, or the project stalls halfway through waiting on a DNS change.
- GTM: permission to create a new container in the client's GTM account (account-level user access plus the ability to publish on the containers you work in).
- Hosting: a Google Cloud project with billing enabled, owned by the client, or an account with a managed sGTM host created in the client's name. You need a role that lets you deploy services, not ownership of the billing account.
- DNS or CDN: someone who can add records for a subdomain, or configure routing on the client's CDN if you want same-origin serving.
- Platforms: GA4 Editor, Google Ads access to conversion actions, and Meta access to the dataset (pixel) so you can generate a Conversions API access token.
- Consent: which consent management platform runs on the site and how it signals consent to GTM. Server-side tagging must respect the same choices.
The single most important decision: everything lives in the client's accounts. The server container sits in their GTM account, the hosting bills their card, the domain is theirs. If the agency relationship ends, tracking keeps running.
Step 1: Create the server container
In the client's GTM account, create a new container and choose Server as the target platform. GTM will offer to provision a tagging server automatically or let you provision it manually. Choose the manual option. It gives you a container config string, which is what your hosting deployment uses to know which container it serves. Copy it somewhere safe; you will paste it into the hosting setup.
A fresh server container comes with a GA4 client already in place. Leave it there; you will use it in step 4.
Step 2: Choose and set up hosting
The server container is a Docker image that Google publishes. Something has to run it. Agencies generally pick between two options.
| Option | Suits | Watch for |
| Google Cloud Run in the client's GCP project (self-managed) | Agencies with someone comfortable in Google Cloud, clients who already use GCP, accounts that want no extra vendor in the data path | Cold starts if instances scale to zero, setting a sensible minimum instance count, IAM, budget alerts, keeping the image updated |
| Managed sGTM host such as Stape, account opened in the client's name | Teams without cloud engineering time, smaller accounts, faster setup | Another processor handling the client's data (check their data processing terms), plan limits on request volume, who holds the login |
Check current pricing for either route against the client's traffic before you commit. Costs scale with request volume, so a high-traffic e-commerce store and a small lead-gen site will look very different. Give the client an estimate in writing before setup, not after the first invoice.
Cloud Run specifics
On Cloud Run you deploy two services from the same image:
- A preview server, which powers GTM's server preview mode. It runs with the environment variable that marks it as the preview server, and it only needs a single instance.
- A tagging server, which handles real traffic. It needs the container config, the URL of the preview server, and enough minimum instances that the first request of the morning is not served cold.
Follow Google's current server-side tagging documentation for the exact deployment settings and recommended instance counts, since these have changed over time. Set the region close to the client's audience. Turn on request logging only at the level you will actually read, because verbose logging on a busy site adds cost.
Managed host specifics
With a managed host you paste the container config into their dashboard and they run both servers for you. Open the account under the client's email or a shared client mailbox, not an agency employee's personal address. Write down which plan you chose and what happens when the request limit is exceeded.
Step 3: Serve it from the client's domain
A tagging server on a default cloud URL works, but you lose most of the benefit. Cookies set by a server on the same site as the page are first-party and tend to last longer than cookies written by JavaScript in browsers with tracking restrictions. There are two ways to do this.
| Approach | Example | Notes |
| Subdomain | sgtm.clientsite.com | Simplest. Add the DNS records your host gives you and wait for the certificate. Works for most accounts. |
| Same origin (path) | clientsite.com/metrics | Requests go to the main domain and the CDN or load balancer routes a path to the tagging server. Google's documentation recommends this where possible. Needs control of the CDN or web server config. |
Pick a neutral subdomain or path name. Names like tracking or analytics are more likely to land on blocklists. Once the domain resolves, add it as the tagging server URL in the server container's settings so preview mode works against the real endpoint.
One alternative worth knowing about: Google's tag gateway, which serves Google tags through the client's domain via a supported CDN without running a full server container. It covers Google tags only, so if the goal includes Meta CAPI and data control, a server container is still the tool.
Step 4: Send GA4 traffic to the server
In the client's web container, open the Google tag that carries the GA4 measurement ID and add the configuration parameter server_container_url with the full tagging server URL. From then on the browser sends GA4 hits to the client's domain instead of directly to Google.
In the server container, the built-in GA4 client claims those requests and turns them into event data. Now create a Google Analytics: GA4 tag in the server container, triggered on all events claimed by the GA4 client, so the data continues to GA4. Publish nothing yet; test first.
Keep your GA4 event design as it was. If the web container already sends generate_lead or purchase with the right parameters, those flow through the server untouched. If the event plan is a mess, fix it before you add a server in the middle. Our GA4 key events and naming plan covers what that should look like.
Step 5: Route Google Ads conversions
In the server container add two things:
- A Conversion Linker tag firing on all GA4 client events, so click identifiers are stored in first-party cookies set by the server.
- A Google Ads Conversion Tracking tag for each conversion action, with the conversion ID and label from the Google Ads account, triggered on the matching event name (for example
generate_lead claimed by the GA4 client).
Pass the conversion value and currency from the event data, and the transaction ID for purchases. If you use enhanced conversions, make sure the user-provided data (email, phone) is present in the event data the server receives, and that it is only sent when consent allows.
Then remove or pause the matching Google Ads conversion tags in the web container. Running a browser Google Ads conversion tag and a server Google Ads conversion tag for the same action without a shared transaction ID is a fast way to double-count leads. Google Ads deduplicates on transaction ID within a conversion action, so for purchases send the order ID from both sides; for leads it is cleaner to send from one side only. Our Google Ads conversion tracking setup guide covers count settings and primary versus secondary actions.
Step 6: Add Meta Conversions API
Meta publishes a Conversions API tag template in the GTM community template gallery. Add it to the server container, enter the dataset (pixel) ID and an access token generated in Events Manager, and trigger it on the events you want Meta to receive.
Map GA4 event names to Meta standard events: generate_lead to Lead, purchase to Purchase, and so on. Pass customer information that the client has consent to share, hashed as Meta requires, along with the fbp and fbc values so Meta can match the event to a browser.
Unlike Google Ads, you usually keep the Meta Pixel running in the browser alongside CAPI. That makes deduplication non-negotiable:
- Generate one
event_id per action in the web container (a data layer value set when the form submits or the order completes).
- Send that same ID as
eventID on the browser Pixel event and as event_id on the server event.
- Make sure the event names match exactly, including case.
If the IDs do not match, Meta counts the lead twice. The full method is in our Meta Conversions API deduplication guide. Also check that no Shopify app or WordPress plugin is already sending server events for the same dataset. Two server sources plus a pixel is a common cause of inflated numbers.
Step 7: Consent
Server-side tagging does not change what the user agreed to. The web container still needs consent mode configured, and the server container should only forward data to platforms when consent signals allow it. The GA4 client passes consent state through to the server, and Google's server tags read it. For the Meta tag and any non-Google tags, add a trigger condition or exception based on the consent state so nothing fires that should not. See our Consent Mode v2 implementation guide for the web side.
Step 8: Test in server preview
Run web preview and server preview together. Web preview shows what the browser sent; server preview shows what arrived, which client claimed it, and which tags fired with what outgoing requests.
- Load a landing page with a test click identifier (for example a URL with a test
gclid and fbclid) and confirm the server sets first-party cookies on the client's domain.
- Submit every form and complete a test purchase if it is a store. For each, confirm in server preview that the GA4 client claimed the request and the GA4, Google Ads and Meta tags fired once with status 200 on the outgoing requests.
- Check the event data tab for the value, currency, transaction ID and
event_id.
- In Meta Events Manager, use the Test Events tool and confirm the browser and server events show as deduplicated.
- In GA4 DebugView, confirm events arrive with the right parameters.
- Refresh the thank-you page and press back. Nothing should fire a second conversion.
Record each test with screenshots. That log is what proves the setup works when the client asks in three months why numbers moved.
Step 9: Publish, then watch it
Publish the server container first, then the web container change that points GA4 at it. For the first week compare daily counts in GA4, Google Ads and Meta against the CRM or store backend. Expect some movement; that is the point. Big drops usually mean a tag is not firing; big jumps usually mean duplicates.
Ongoing monitoring should cover:
- Uptime: an uptime check on the tagging server's health endpoint, with alerts to someone who will act.
- Errors: outgoing request failures in the server logs, especially after a platform changes an API.
- Cost: a budget alert in Google Cloud or a usage alert with the managed host, set at a level the client agreed to.
- Image updates: on self-managed hosting, redeploy when Google ships a new server image.
Common mistakes
- Pointing GTM preview at the tagging server. The preview server and tagging server are separate deployments with separate roles.
- Leaving the default cloud URL in place. You get the cost of server-side without the first-party cookies.
- Firing Google Ads conversions from both browser and server. Pick one side per action, or deduplicate with a transaction ID.
- No event_id for Meta. Pixel plus CAPI without a shared ID counts every lead twice.
- Forgetting consent on server tags. Non-Google tags in particular do not respect consent on their own.
- Hosting in an agency or freelancer account. When people move on, the client loses tracking and nobody can find the login.
- Scale-to-zero on a production tagging server. Cheaper, but cold starts can drop or delay hits.
Documentation to hand over
A server container nobody understands gets switched off at the first problem. Leave the client, and your own team, with:
- An architecture note: which events enter the server, which client claims them, which tags send them where.
- Hosting details: provider, project or account name, region, instance settings, who has access, where the budget alert goes.
- The domain or path setup and where the DNS or CDN record lives.
- Credentials inventory without the secrets themselves: which Meta token is in use, who generated it and how to rotate it.
- The test log with screenshots and the date of each test.
- A short runbook: how to check the server is up, how to roll back to the previous container version, who to call.
Getting it done for a client account
If you would rather hand this off, our server-side tracking service sets up sGTM in the client's own accounts under your agency's name, with the architecture notes and test log included. It starts with a free tracking check to confirm server-side is worth it for that account.