4

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.

0

2 Answers 2

1

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.

2
  • I set the Preview to the main domain via the three stripes button as you suggested. Now the page loaded only shows an error: Server Unavailable! Server unavailable.Please visit again later. Does this mean tag server cannot reach the preview server? Is it normal that i never see any logs in the preview server container? About the second part of the comment: the preview server was already not accessible from internet, it's exposed via an internal ingress, while the tag server is exposed via an external ingress.
    – giacom0c
    Commented Apr 20, 2023 at 15:42
  • Unfortunately, I don't have experience from this error message. Do you see this when opening the preview from GTM? If the /healhz works on both domains it indicates that there could be an issue with the configuration or connection between the servers. Are you sure you have set the RUN_AS_PREVIEW_SERVER and PREVIEW_SERVER_URL environment variables correctly? PREVIEW_SERVER_URL should contain the https:// part.
    – lari
    Commented Apr 20, 2023 at 20:38
1

Did you set the PREVIEW_SERVER_URL variable on the main container as it is suggested here https://www.simoahava.com/analytics/cloud-run-server-side-tagging-google-tag-manager/

shot

Not the answer you're looking for? Browse other questions tagged or ask your own question.