Built for Shopify & WooCommerce · Tracking checked every 30 minutes.

GA4 server-side tracking with Google Tag Manager: the full setup

Abir Molla
Abir MollaNov 20, 2026 · 11 min read
GA4 server-side tracking with Google Tag Manager: the full setupVideo · 18:25 · plays from YouTube

GA4 server-side tracking means your website's Google tag sends its events to your own server-side Google Tag Manager container, instead of straight to Google Analytics. The server container's GA4 client receives each event, and a GA4 tag on the server forwards it to Google. To set it up you need a web container, a server container hosted on Google Cloud or a managed hosting service, a subdomain of your site such as sst.yourstore.com, and one setting on your Google tag: server_container_url.

The video above shows the whole setup on a WooCommerce store, with the server on a managed host. This post is the written version: the steps in order, how to test them in both preview modes and in GA4's DebugView, and the mistakes I see most.

The video is from December 2022, and Google Tag Manager has changed since. The GA4 Configuration tag I use in the video is now the Google tag, and its "Send to server container" tick box is gone: you add a server_container_url parameter instead. Universal Analytics has been switched off, so only the GA4 client in the server container matters. And Google now runs its own tagging servers on Cloud Run. The steps below are the current way.

What GA4 server-side tracking is, and why use it

With a normal setup, the GA4 code in your visitor's browser sends every event to Google's own domain. With server-side tracking, the browser sends the same events to a server you control first. That server runs a Google Tag Manager server container, which decides what goes on to Google Analytics.

There are two good reasons to do it:

  • It runs on your own domain. When the server lives on a subdomain of your site, its requests are first-party, part of your own website. Google says the tagging server and your website must share a domain to get first-party benefits, such as more durable cookies (Google, custom domain for server-side tagging). Requests to your own domain are also less likely to be blocked than requests to a known tracking domain.
  • You control the data. Every event passes through your server before it reaches Google. You can see it, add details, or remove ones you don't want to share. And the same server can send those events to other platforms too, such as Meta's Conversions API.

What it doesn't do: it doesn't fix a broken data layer, and it doesn't replace consent. If the browser never sends an event, the server never sees it.

What you need

  • A GA4 property with a web data stream for your site, and its Measurement ID (it starts with G-). This guide shows where it is.
  • A Google Tag Manager web container on your site, with a data layer that sends your ecommerce events: product views, add to cart, checkout and purchase.
  • A Google Tag Manager server container. You create it in the same account.
  • A place to run the server container. In the video I use a managed hosting service. Google Cloud works too. Google Cloud needs a billing account, and Google estimates about $45 a month for each server, with at least 2 servers recommended for a live site (Google, set up server-side tagging with Cloud Run).
  • A subdomain of your site, such as sst.yourstore.com, and access to your domain's DNS settings.

Step 1: get your web container and data layer ready

Go to tagmanager.google.com, create an account if you don't have one, and add a Web container for your site. If Google Tag Manager is already on your site, use that container. Don't make a second one.

In the video the store runs on WooCommerce, so I install Google Tag Manager with the GTM4WP plugin. Paste your container ID (GTM-…) into the plugin's settings, then turn on WooCommerce tracking in its Integration tab. That makes the plugin push your shop's ecommerce events into the data layer.

Check it before you go further. Click Preview in Google Tag Manager, open your site, view a product and add it to the cart. In the Preview panel you should see the ecommerce events arrive with their products in the data layer.

On Shopify, the steps are different. The checkout and thank-you pages don't run your theme's code, so the data layer has to come from a custom pixel under Settings → Customer events. The Shopify GA4 ecommerce tracking guide covers that part. The server-side steps below are the same on any site.

Step 2: create the GA4 property and web data stream

In Google Analytics, create a property if you don't have one: name it, pick your time zone and currency, and answer the business questions. Then go to Admin → Data collection and modification → Data streams, choose Web, enter your website address and click Create stream.

Copy the Measurement ID. You'll paste it into Google Tag Manager in the next step.

Step 3: set up the Google tag and GA4 event tags

Get GA4 working in the browser first. The server only forwards what the browser sends, so a problem here becomes a problem everywhere.

In your web container:

  • The Google tag. Create a Google tag, put your Measurement ID in Tag ID, and fire it on Initialization - All Pages.
  • The GA4 event tags. Create one Google Analytics: GA4 Event tag for each ecommerce event: view_item, add_to_cart, begin_checkout and purchase. Each one needs the same Measurement ID, the items from the data layer, plus value and currency. The purchase also needs transaction_id. Fire each tag on a Custom Event trigger that matches the event name in your data layer.

In the video I save time by importing a ready-made container: Admin → Import container, choose the JSON file, pick your workspace and Merge. The tags, triggers and variables arrive already built, and you only change the Measurement ID.

Test it before moving on. Turn on Preview, then in GA4 open Admin → Data display → DebugView. Preview mode turns on GA4's debug mode for your browser, so your events show in DebugView as you browse (Google Analytics Help, monitor events in debug mode). Add a product to the cart, start checkout and place a test order. You should see each event, and the purchase should carry its items.

Step 4: create the server container

In Google Tag Manager, open Admin, click + in the Container column to create a container, give it a name and choose Server. Then pick how the server is hosted:

  • Automatically provision tagging server sets up the server on Google Cloud for you. You choose or create a billing account, and Google Tag Manager deploys it on Cloud Run.
  • Manually provision tagging server gives you a Container Config string. Copy it. This is what you paste into your host.

In the video I choose manual, because the server runs on a managed host.

Step 5: host the server and add your subdomain

In your hosting service, create a new container. Paste the Container Config, give it a name, and choose the server location closest to your customers. The video uses Singapore. Pick a plan and wait until the container shows as running.

Then add your subdomain. In the video I leave this to the end, but do it now: without it, the server runs on your host's own domain, and Google says a server on the default domain can only set JavaScript cookies, not server-set ones (Google).

  1. Add a subdomain such as sst.yourstore.com in your host's domain settings.
  2. Add the DNS record your host shows you where your domain's DNS is managed, then wait for it to verify. Avoid names like analytics or track, which ad blockers often block.
  3. In the server container, go to Admin → Container Settings, click Add URL, paste https://sst.yourstore.com and save.

Google also supports serving the server from a path on your main domain, such as yourstore.com/metrics, and calls that the best practice. It needs a CDN or load balancer in front of your site, so a subdomain is the simpler route for most stores.

To check the server is up, open your server address with /healthy on the end. A working server answers ok.

Step 6: add the GA4 client and the GA4 tag on the server

A server container works in two parts. A client receives the incoming requests and turns them into events. A tag sends those events somewhere.

The GA4 client. In the server container, open Clients. The GA4 client is there by default. Open it and keep Default GA4 paths ticked, so it picks up the requests your Google tag sends (Google, configuring the GA4 data stream). Under Cookies and Client Identification, Google's own course uses JavaScript Managed, and that's the safe start. Server Managed lets your server set the GA4 visitor cookie itself, which only makes sense once the server runs on your own subdomain. It's what I mean at the end of the video by making the cookies last longer.

The GA4 tag. Go to Tags → New and choose Google Analytics: GA4. You can leave the fields as they are: the tag takes the Measurement ID and the event details from the incoming event.

The trigger. Click Triggering → +, choose Custom, then Some Events. Pick the built-in variable Client Name, set it to equal GA4, and save. That makes the tag fire for every event the GA4 client receives. Save the tag.

Step 7: point the Google tag at your server

This is the step I missed the first time in the video, and nothing reached the server until I fixed it.

Back in the web container, open the Google tag. Under Configuration settings, add a parameter:

  • Name: server_container_url
  • Value: https://sst.yourstore.com

Save it. Your GA4 event tags use the same Measurement ID, so they follow the Google tag's settings and send to your server too.

Step 8: test in both previews and DebugView

You need two preview windows open at once.

  1. Server preview first. In the server container, click Preview. It opens in its own tab.
  2. Then web preview. In the web container, click Preview, enter your site's address and connect.
  3. Do a real journey. View a product, add it to the cart, start checkout and place a test order.

Now check three places:

  • Web preview: the Google tag and each GA4 event tag fired.
  • Server preview: each event shows on the left, such as collect?v=2 requests. Click one. The GA4 client claimed it, the GA4 tag fired, and under the outgoing requests you'll see it sent on to Google Analytics.
  • GA4 DebugView: the same events arrive, with the purchase and its items.

For one more check, open your browser's developer tools, go to the Network tab and filter by your subdomain. The GA4 requests should go to sst.yourstore.com, not to Google's domain.

When it all looks right, Submit and Publish both containers. Nothing changes for your real visitors until you do.

Common mistakes

The Google tag has no server_container_url. The events still go straight to Google, and the server preview stays empty. This is the mistake in the video.

The server runs on the host's default domain. It works, but you lose the first-party cookie benefits. Add your own subdomain.

The trigger checks the wrong name. The server trigger needs Client Name equals GA4, the client's name. If the GA4 tag never fires in the server preview, check this first.

Only one container was published. The web and server containers are published separately. Publish both.

Another app still sends to the same GA4 property. A plugin, Shopify's Google & YouTube app or an old hard-coded tag sends its own copy of each event, and your numbers double. Keep one source of GA4 events.

Testing with consent denied or an ad blocker on. Google says events don't show in debug mode if privacy controls block them on the page (Google Analytics Help). Accept your cookie banner and turn off blockers while you test.

Questions people ask

Is GA4 server-side tracking worth it?

For a store that runs ads and relies on GA4, usually yes. Your tracking runs on your own domain, you control what reaches Google, and the same server can feed your ad platforms. For a small blog, the browser-only setup is often enough.

Do I still need the Google tag in the browser?

Yes, in this setup. The browser still collects the events and sends them to your server instead of to Google. The server takes it from there.

Google Cloud or a managed host?

Both run the same Google Tag Manager server container. Google Cloud is Google's own option and you manage it yourself. A managed host handles the hosting for you and is simpler if you're not a developer. That's why I use it in the video.

Does server-side tracking get around cookie consent?

No. Consent still applies. Your consent banner and consent mode settings decide what the browser sends, and the server only receives what the browser sends.

Can the same server send my events to Meta?

Yes. Once GA4 events reach your server container, you can add a Meta Conversions API tag that uses the same events. Here's how: set up the Facebook Conversions API with Google Tag Manager.

Where KiteTrack fits

KiteTrack builds and runs this setup for you. It runs your own tracking server on your store's subdomain and sends your events to GA4, Google Ads, Meta and TikTok from it. Customer details are hashed before they leave the server, and your tracking is checked every 30 minutes, so a broken event becomes an alert, not a gap you find weeks later. See how KiteTrack works, or the GA4 server-side setup for Shopify.

Not sure what your GA4 setup is sending? Start with the free Tracking Check. It looks at your site in about two minutes, no signup. If you'd rather talk it through, book a call with me.

Sources

Get tracking tips by email

Short, practical fixes for Meta, Google Ads and GA4, from Abir.

You’re in. First tip lands soon.

Abir Molla
Written by Abir Molla

Tracking specialist. He builds and runs KiteTrack, and explains tracking on YouTube.

Keep reading

Let your ads see every sale.

30-day money-back guarantee · free migration · cancel any time