Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

400 Error code using Cloud Run

My project uses Cloud Run to run Server-side Google Tag Manager only for the purpose to send pageviews to Google Analytics GA4.

I cannot tell why I am continually getting a 400 error code.

I am using one Cloud Run project and a Load Balancer, plus a GTM Web and Server container.

But how is the Cloud Run project linked to the Load Balancer?   It is not obvious in Google Cloud.

How do I ensure everything is pointing correctly to each other? 

My DNS has a A record pointing to the static IP address of the load balancer backend.

Online documentation tells me not to use Cloud Run custom domains mappings and to point directly to the load balancer.

Despite over 150 hours of reading documentation, ChatGpt etc. I am still getting the 400 error code.

Desperate for help!    Thank you.

Mark

0 1 135
1 REPLY 1

Hi @uworlds ,

Welcome to Google Cloud Community!

I understand how annoying this must be after all the effort you've put into resolving it. The 400 error probably indicates that the GTM Server-Side is not managing the requests correctly.

Here’s what you need to check and verify:

  1. Cloud Run & Load Balancer Connection – Make sure your Load Balancer’s backend uses a Serverless NEG pointing to Cloud Run. (Setup Guide)
  2. DNS & GTM Server URL – Your DNS A record should point to the Load Balancer’s static IP. Also, in GTM > Admin > Container Settings, confirm the "Server Container URL" matches your domain.
  3. Fix the 400 Errors – In GTM’s Preview mode, see if your requests are being handled. If they aren't, check if your GA4 client is properly configured to accept them.
  4. Enable Logging – In Cloud Run, enable logs to capture incoming requests. (Monitoring Guide)

Additionally, smart choice in steering clear of Cloud Run’s custom domain mapping—I would recommend to stick with the Load Balancer setup.

Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.