Tracking

Server-side GTM on Google Cloud: when a store needs it

What running your own server-side Google Tag Manager container on Google Cloud involves, when a store needs it, and when a managed setup is enough.

·7 min read·By the ROASaurus team

Key takeaways
  • Server-side tracking needs a server; with server-side Google Tag Manager (sGTM) you rent and run that server yourself, usually on Google Cloud.
  • A Google Cloud setup has five parts: a Cloud project with billing, the server container, a first-party subdomain, the tags that route events, and monitoring.
  • It makes sense when you need full control over where data is processed, custom routing to several destinations, or you already run on Google Cloud with developers to maintain it.
  • For a store that sends purchases to GA4 and the main ad platforms, a managed server-side setup gives the same events without a server to look after.
  • The two can be combined: a managed tool can send its server events into your own container.

Server-side Google Tag Manager on Google Cloud means you run your own tagging server: a Google Tag Manager server container hosted in your own Google Cloud project, on a subdomain of your store. Events from your site go to that server first, and the server sends them on to GA4, Meta, TikTok and other platforms. You get full control over the data, and you also take on the setup, the hosting bill and the maintenance.

Most stores do not need that much control. This guide explains what a Google Cloud setup involves, when it is the right choice, when a managed setup does the same job with less work, and how the two fit together.

What Google Cloud server-side tracking really means

Browser tracking sends events straight from the shopper's browser to each ad platform. Ad blockers, cookie limits in Safari and Firefox, and declined consent stop part of those events. Server-side tracking moves the sending to a server you control, which is harder to block and can add data from your store, such as the order value after discounts.

The catch is easy to miss: server-side tracking needs an actual server, and that server has to live somewhere. There are two ways to get one:

Managed server-side tracking
  • The tracking tool runs the servers
  • You connect accounts and choose destinations
  • Hosting and updates are part of the subscription
  • Less freedom to add custom logic
Your own sGTM container on Google Cloud
  • You run a GTM server container in your own Cloud project
  • You decide every tag, rule and destination
  • You pay Google Cloud for hosting and keep it running
  • Needs a developer or a tracking partner
Both are server-side tracking. The difference is who owns and runs the server.

With your own container, events take this route:

Store and browserPage views, add to cart, checkout and purchase events
Your sGTM containerOn a subdomain such as sgtm.yourshop.com, hosted in your Google Cloud project
Server tagsGA4, Google Ads, Meta, TikTok or your own endpoint
A self-hosted setup: every event passes through a server you run before it reaches a platform.

The parts of a Google Cloud setup

A working setup is more than one tag. It ties several systems together, and each one has to be right for the tracking to stay stable and lawful.

1. A Google Cloud project

Everything starts with a project in your Google Cloud account, with billing turned on. Google Tag Manager can create the server for you (on Cloud Run) or you deploy it by hand. Access rights (IAM roles) decide who can change the server. A careless setup here either stops the container from running or leaves it open to people who should not have access.

2. The GTM server container

In Google Tag Manager you create a container of the type Server. It receives requests through clients (for example the GA4 client or the Measurement Protocol client), turns them into event data, and passes that data to tags that send it on. This is where custom logic lives: filtering bot traffic, enriching events with data from your store, or adding a user id.

3. A first-party subdomain

To keep the tracking first-party, the container runs on a subdomain of your store, such as sgtm.yourshop.com. That takes a DNS record at your domain registrar and a certificate. Without it, requests go to a Google-owned address and lose much of the benefit against browser limits.

4. Tags that route the data

Each destination needs its own server tag: GA4 receives events in its own format, Meta through the Conversions API, TikTok through its Events API, and so on. Many of those tags come from the community template gallery, so check who maintains each one. Purchases must carry an event id that matches the browser event, or platforms count them twice.

5. Consent and monitoring

The server must respect the visitor's consent choice, just as the browser tags do. It also needs watching: logs to see failed requests, alerts when the server stops, and updates when Google releases a new server image. Plan who does this every month, not only at launch.

When a Google Cloud setup makes sense

Running your own container is the right choice in a few clear cases:

  • You need full control over the data path. Legal, contract or internal policy requires that you decide where customer data is processed and what is removed before it leaves your systems.
  • You have advanced routing needs. The same event goes to several places at once (GA4, a custom endpoint, a data warehouse), rules differ per language, region or Shopify Market, or one container serves several stores and domains.
  • You already run on Google Cloud. If BigQuery, Cloud Functions or other parts of your stack are there, the container fits into the same billing, access rules and monitoring.
  • You have developers or a tracking partner. A self-hosted container is a developer project. Someone has to test releases, read logs and fix tags when a platform changes its API.

When you probably do not need it

  • You want to go live without a project. A Google Cloud setup takes planning, DNS changes and testing before the first event arrives.
  • You watch costs closely. You pay Google Cloud for the server every month, with more instances as traffic grows, plus the hours someone spends maintaining it. Check the current price with the Google Cloud pricing calculator before you decide.
  • You send standard events to standard platforms. If you need purchases and the usual shopping events in GA4, Meta, Google Ads and TikTok, a managed tool already does that server-side.
QuestionManaged setupOwn sGTM on Google Cloud
Who runs the server?The tracking toolYou or your partner
Hosting billIn the subscriptionGoogle Cloud, monthly, grows with traffic
Custom logic per eventSettings the tool offersAnything you can build in tags
Updates when a platform API changesThe tool updatesYou update the tags
Who it suitsMost storesStores with strict data rules or custom pipelines
A rough guide. Many stores start managed and add their own container only when a real requirement appears.

How to plan a Google Cloud setup

  1. Write down the requirement

    Name the rule or pipeline that a managed tool cannot meet. If there is none, a managed setup is simpler.

  2. Decide which events go where

    List each event (page view, add to cart, checkout, purchase, refund) and each destination, with the event id that ties browser and server together.

  3. Set up the project and the container

    Create the Cloud project with billing and access rules, provision the server container, then map the subdomain and wait for the certificate.

  4. Add clients, tags and consent checks

    Configure the clients that receive data, one tag per destination, and the consent rules that stop events for visitors who declined.

  5. Test in preview, then watch

    Use the server preview to check every event, compare purchases with your orders for a week, and set alerts for failed requests.

How ROASaurus fits, with or without your own container

ROASaurus runs server-side tracking for you: it sends paid orders from your store's order data to 16 ad platforms, GA4 and Klaviyo, with the same event id as the browser event, so nothing has to be hosted. If you also run your own container, add it as a destination under Connections › Tracking & destinations as Server-side GTM. You enter the Container URL (an https:// address such as https://sgtm.yourshop.com), the Client path of your Measurement Protocol client (default /mp/collect) and, if you want, a GA4 Measurement ID, an API secret and a preview header for testing.

Your storeThe order is paid
ROASaurusBuilds the event from the order, with the same event id as the browser
Your sGTM containerMeasurement Protocol client at /mp/collect
Your server tagsAny destination you configure
ROASaurus posts each event in the GA4 Measurement Protocol format to your container, where your own tags take over.

ROASaurus forwards page views, product views, add to cart, checkout, purchases, leads and refunds this way. Events from visitors who declined marketing consent are not forwarded, because your container's tags could send them anywhere. Each delivery and the container's response appear in Data quality › Deliveries, so you can see what reached the server. Two things are not built yet: a storefront data layer for your own browser GTM container, and ready-made GTM templates for the ROASaurus events.

Next step

Sources

  1. Google Tag Manager: An introduction to server-side tagging
  2. Google Tag Manager: Set up server-side tagging with Cloud Run
  3. Google Tag Manager: Map a custom domain to your tagging server
  4. Google Tag Manager: Send data to server-side Tag Manager

In ROASaurus

Keep reading

Tracking"No recent conversions" in Google Ads: causes and fixesWhat "No recent conversions" (now "Awaiting conversions") means in Google Ads, how to tell a quiet week from a broken tag, and the fix.TrackingCookieless tracking for online stores: what still worksCookieless tracking for online stores: server-side events, modeling and fingerprinting compared, what each still measures and what consent requires.TrackingGoogle Ads conversion tracking problems on ShopifyWhy Google Ads counts too few, too many or wrongly valued Shopify purchases, what each status and warning means, and a health check to find the cause.

FAQ

Questions, answered

More answers in the FAQ and the help center.

Do I need Google Cloud for server-side tracking on Shopify?

No. Server-side tracking needs a server, but a managed tracking tool can run it for you. Google Cloud is one place to host your own server-side GTM container when you need full control.

What does a Google Cloud server-side setup include?

A Cloud project with billing and access rules, a GTM server container, a first-party subdomain with DNS and a certificate, server tags for each destination, consent rules, and monitoring.

When does a Google Cloud setup make sense?

When you must control where data is processed, need custom routing to several destinations or stores, already run on Google Cloud, and have developers or a partner to maintain it.

What does hosting server-side GTM cost?

You pay Google Cloud for the server instances every month, and the bill grows with traffic. Add the time someone spends on updates and monitoring. Use the Google Cloud pricing calculator for a current estimate.

Can I use a managed tool and my own container together?

Yes, as long as each platform gets each purchase once. ROASaurus can forward its server events to your container in the GA4 Measurement Protocol format, and your tags take it from there.

Every sale, traced to the ad that earned it

Server-side tracking, profit and lifetime value in one app. Free plan, no credit card.