Skip to content

Debug and test your server-side setup

A server-side setup has more moving parts than a web container: the browser, your subdomain, the server container and the vendors behind it. When data goes missing, you find the break by following one hit along that path. This lesson shows the tools for each step and the problems that come up most often, with their fixes.

Intermediate 9 min read

What you will learn

  • Run web and server Preview side by side and read what the server container did with each request.
  • Confirm in DevTools and GA4 DebugView that hits reach your subdomain and GA4.
  • Recognise and fix the most common causes of missing server-side data.
  • Use the SGTM.space container tabs to check health, DNS, traffic and your live install.

Before you start

  • A server container running on your subdomain (lesson 2).
  • GA4 sending to that subdomain from the web container (lesson 3 and lesson 4).

01 Run web and server Preview side by side

GTM Preview works in both containers at once. The order matters: the server Preview session has to be open before the web Preview sends anything, and both must run in the same browser.

  1. 1 Open the server container in GTM and click Preview. A Tag Assistant tab opens on sgtm.example.com. Leave it open.
  2. 2 In the same browser, open the web container and click Preview. Enter your website address and click Connect.
  3. 3 Click around the site and trigger the event you want to test.
  4. 4 Switch to the server Preview tab. Each incoming request appears in the left column.

Select a request and read it from top to bottom:

  • Request: the incoming HTTP request, and the Client that claimed it. A GA4 hit should be claimed by the GA4 client.
  • Tags: which tags fired and which did not. A tag that did not fire usually has a trigger that did not match.
  • Outgoing HTTP requests (on the Request tab): what the server sent to GA4 or another vendor, and the status code it got back. A 2xx status means the vendor accepted it.
  • Event Data: the parameters the client extracted. Check that your event name and parameters arrived.

02 Check the browser and GA4

Preview tells you what GTM did. Two more checks confirm what actually left the browser and what arrived in GA4.

  1. 1 Open DevTools (F12), go to the Network tab and filter by collect.
  2. 2 Reload the page. You should see requests to your own subdomain, not to google-analytics.com.
  3. 3 Check the status: 200 or 204 means your tagging server accepted the hit.
text
https://sgtm.example.com/g/collect?v=2&tid=G-XXXXXXXXXX&en=page_view&...

Then open GA4, go to Admin, then Data display and DebugView. Events from a browser in GTM Preview are marked as debug traffic automatically. Outside Preview, add the debug_mode parameter with the value true to your Google tag to see them there.

03 Common problems and how to fix them

Most broken setups fail in one of these places. Work through them in order, from the DNS to the vendor.

  • Check DNS fails or the subdomain does not resolve. The record may still be propagating (wait up to an hour), the name may contain the domain twice (sgtm.example.com.example.com, because some panels add the domain for you), or Cloudflare proxying is on. On Cloudflare the record must be DNS only (gray cloud), not the orange cloud.
  • Wrong or old Container Config. If the server container in Preview does not match the one you edit in GTM, copy the Container Config again from Admin and Container Settings and make sure your SGTM.space container uses exactly that string. A config from another server container sends your traffic to the wrong one.
  • Hits still go to google-analytics.com. The server_container_url parameter is missing from the Google tag, has a typo, or the web container was not published after you added it. See lesson 3.
  • It works in Preview but not for real visitors. The server container was never published. Preview uses your workspace, live traffic uses the published version. Click Submit and Publish in the server container.
  • Requests arrive but nothing reaches GA4. The server container has no GA4 tag, or its trigger does not match. Add a Google Analytics: GA4 tag triggered by Client Name equals GA4, as shown in lesson 4.
  • Hits are missing for some visitors. Ad blockers can still stop requests, and with Consent Mode tags may not fire or send cookieless pings until the visitor accepts. See lesson 6 and lesson 8.
  • All requests are suddenly rejected. The container has reached the request limit of its SGTM.space plan. Requests are turned away until the limit is raised or the period resets. The Analytics tab shows how close you are.

04 Use the SGTM.space container tabs

Each container in SGTM.space has tabs that answer the questions GTM cannot.

  • Overview: the container status and its health checks. Start here when nothing arrives at all.
  • DNS: the records to add and their state. Use Check DNS after every change.
  • Analytics: the number of requests per day. A sudden drop to zero points to a broken install or a DNS change, not to GA4.
  • Preview Mode: sends matching requests from webhooks, a CRM or your backend into your open server Preview session for 60 minutes.

Preview Mode helps when the requests do not come from your browser, so the normal Preview cookie is missing.

  1. 1 Open Preview in the server container. In the top-right menu choose Send requests manually and copy the X-Gtm-Server-Preview header value.
  2. 2 In SGTM.space open the Preview Mode tab and paste the token.
  3. 3 Optionally set a path prefix (for example /webhooks) and a source IP, so only those requests are forwarded.
  4. 4 Click Save and start for 60 minutes and trigger the webhook or backend call. It appears in your Preview session.

05 A quick test checklist

  • https://sgtm.example.com/healthz returns 200 and the container is Ready in Overview.
  • DevTools shows collect requests to your subdomain with status 200 or 204.
  • Server Preview shows the request claimed by the GA4 client.
  • The GA4 tag fired and its outgoing request got a 2xx status.
  • The event appears in GA4 DebugView.
  • Both containers are published.

Frequently asked questions

Why is the server Preview empty while the web Preview shows events?

Either the hits do not go to your subdomain (check server_container_url and the Network tab), or the server Preview was opened in a different browser or after the web Preview. Open the server Preview first, then start the web Preview in the same browser.

Can I debug requests from my backend or a webhook?

Yes. Copy the X-Gtm-Server-Preview token from Send requests manually in the server Preview and paste it into the Preview Mode tab in SGTM.space. Matching requests show up in your Preview session for 60 minutes.

GA4 shows fewer events than the Analytics tab. Is data lost?

Not necessarily. The Analytics tab counts every request your container receives, including script loads, bots and events that no tag forwards. Compare a single event in Preview and DebugView instead of totals.

Ready to put it into practice?

Deploy a server GTM container on your own domain in a few minutes. The Free plan needs no card.

Create a free account