Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preview mode for GTM Server-Side tagging is not working with manual setup

I'm trying to migrate my Google Tag Manager to the Server-Side version. The workflow is actually working, the client container sends data to the server container and finally I see the tracking arriving in GA4. What is not working is the Preview server.

My Server-Side and its Preview are deployed as distinct deployments in a K8s on premises. I have 1 ingress for each of those, and they expose respectively analytics.mydomain.com and preview.mydomain.com. Sending an HTTP request to /healhz on both of these domains return OK.

Now, when I hit the preview button on the client container menu in my browserenter image description here I can successfully load the Preview dashboardenter image description here But if I reload the page I'm tracking, I don't see any new events collected. Moreover, if I use the "Send request manually" option using this curl

curl -H 'x-gtm-server-preview: ZW52LTN8X1VtScensoredDYxN2M4MDkyMzU3ODRhYzYxOWM==' 'https://preview.mydomain.com/g/collect?v=2&en=page_view&tid=G-1234&cid=123.456&dl=https%3A%2F%2Fexample.com%2F'

The response I got is Not Found.

What could possibly be the issue here? I also tried to deploy it outside K8s in a simple docker container but I had the same problem, It won't load events and will always respond Not Found.

like image 391
giacom0c Avatar asked Oct 30 '25 23:10

giacom0c


1 Answers

Based on the "send request manually" example, it looks like you are trying to preview the preview server. This doesn't work. When you click on the three stripes next to the "Preview" button, you should select the main domain (e.g. analytics.mydomain.com) and not the preview server domain.

The preview server doesn't event have to be publicly accessible from the internet as long as the main servers at analytics.mydomain.com are able to access it. The connection to the preview server happens in the background server-to-server.

like image 78
lari Avatar answered Nov 02 '25 08:11

lari