Search code examples
google-tag-managergoogle-cloud-rungoogle-tag-manager-server-side

sGTM's /gtm/debug mode throw 400 Bad Request


I'm starting with migration from GTM so Server GTM. I have set up everything in Google Cloud Run with Loadbalancer for our testing-env and everything works fine.

Now I've setup everything for our production system but the GTM Debug mode is not working and throw's Error 400 Bad Request - I use the same setting and config as in the testing-env:

enter image description here

The state in https://sst.myserver.com/healthz says also OK.

After some search for the error in the web, some say that if the server throw's 400, a client is missing. But I've connected also GA4 with it and the data is coming to GA4. Only the debug mode is not working under /gtm/debug/...

Any ideas?


Solution

  • Finally I found the issue. The preview-server did not run correctly as preview-server. In Cloud Run the env var name 'RUN_AS_PREVIEW_SERVER ' had an empty space which lead that the preview server was startet as regular server. And the regular server is not allowed handle the /gtm/debug request correctly.