> Site index: https://usehardal.com/llms.txt
> Every content route also serves markdown at <url>.md

# What Is Server-Side GTM?

Server-side Google Tag Manager runs a container on a server. It receives event requests, keeps the fields you select, and forwards them through configured tags.

Source: https://usehardal.com/glossary/server-side-gtm

---

Server-side Google Tag Manager (sGTM) is a Google Tag Manager container that runs on a server instead of in the browser. The browser or app sends a hit to your tagging server. A client inside the container turns that HTTP request into event data. Tags then forward the fields you select to analytics and advertising tools.

The container is a router with rules. It does not invent events that nobody sent, and it does not decide that a visitor consented.

## How does a server container work?

A server container has three parts you configure.

1. **The tagging server URL.** You host the container and usually map it to a hostname you control, such as `metrics.example.com`. The website tag sends hits to that host.
2. **A client.** The client claims incoming requests that match its format and parses them into the event data model. The GA4 client claims Google Analytics 4 collection requests.
3. **Tags, triggers, and variables.** A trigger decides when a tag runs. The tag maps event data into the destination's API. A variable reads one field, such as the event name or a consent flag.

Preview mode shows the incoming request, the event data the client built, and which tags fired. Use it before you publish. A tag that never fires is a configuration gap, not missing customer activity.

## A concrete example

A site sends GA4 hits to `https://metrics.example.com/g/collect`. One request includes `en=page_view` and the GA4 measurement ID. The GA4 client parses that request and sets `event_name` to `page_view`.

A GA4 tag, triggered on all events the GA4 client claims, forwards `page_view` to Google Analytics. A second tag is triggered only when `event_name` equals `purchase`. It reads `transaction_id`, `value`, and `currency` from event data and sends a purchase to an ads API. A page view does not fire the purchase tag.

If the same purchase is also sent by a browser pixel, both copies need the same event ID. See [event deduplication](https://usehardal.com/glossary/event-deduplication).

## What are the limits?

The server only sees requests that arrive.

- **Collection still starts on the device or in your backend.** An ad blocker, a closed tab, or a denied permission can stop the hit before your container sees it. Hosting the endpoint on your domain does not guarantee the request is delivered.
- **Safari ITP still applies.** A first-party hostname does not disable Intelligent Tracking Prevention or grant a longer cookie lifetime than Safari allows.
- **Consent is an input, not an output.** Google Consent Mode and your consent platform still decide storage and ads behavior. The container should drop or trim fields when the incoming consent state does not allow the destination.
- **Duplicate paths double-count.** A browser tag and a server tag that both report `purchase` for order `order-123` need one shared ID or the destination may count two purchases.
- **Diagnostic traffic is not a conversion.** A `gtg_health=1` request checks that the Google tag loaded. Do not map it to a business event.

Moving a tag to the server can shorten the work the browser does for that tag. It does not repair a wrong event name, a missing `transaction_id`, or a purchase that the checkout never recorded.

## How Hardal handles it

Hardal hosts the server-side GTM container, along with other server destinations, so the tagging server is not a separate cloud project you have to run. The container still forwards only the events your site, app, or backend sends, and only the fields its tags are allowed to use.

For the collection pattern around the container, see [server-side measurement](https://usehardal.com/glossary/server-side-measurement). For a direct backend call that never passes through the browser, see [server-to-server](https://usehardal.com/glossary/server-to-server). The [cookieless GA4 setup](https://usehardal.com/server-gtm-cookieless-ga4) shows how consent state and the server container fit together.

**Related terms:** [Server-side measurement](https://usehardal.com/glossary/server-side-measurement), [Server-to-server](https://usehardal.com/glossary/server-to-server), [Event deduplication](https://usehardal.com/glossary/event-deduplication)
