Stape
Search
Try for free

Server GTM container is not receiving requests - reasons and fixes

Published
Oct 11, 2024

When you’ve decided to try server-side tracking and chose Stape hosting (although in the context of this post - it doesn’t matter what hosting provider you have), you first create a server Google Tag Manager (sGTM) container. Next, you connect your subdomain to it. Finally, your server preview is up and running. After all this is done, all that’s left is to configure the tags.

You start by studying videos and articles on configuring a platform, making changes to your configuration settings within Google Tag Manager, running the preview, and…nothing happens. 

Correctly configuring GTM settings is crucial for effective event tracking and data management. Your server preview is empty; the Google Tag Manager container receives no requests. What should you do now?

Worry not! We have an answer for you.

Reason 1. Basic issues

Sometimes the problem lies in the simplest things that could easily be fixed. Review the following basic issues to check if you’re on top of everything.

How to check and fix this

1. Ensure that the preview server functions properly during the setup process. It can only work correctly in the Chrome browser, so make sure you have it updated to the latest version. 

2. Check that your server GTM container preview is working. When you run it, you should see something like this.

3. In your browser, go to your subdomain and add /healthy to your subdomain link. Everything is set up correctly if you see ‘ok’ on display. 

4. Start the server container preview; in the add tab, just go to your server container URL and add /test to it. If you see a ‘400’ error on the page - that’s fine. You should see this request in the preview.

If the basic checks above pass, technically, everything will be fine with your server container, and the problem with not receiving requests is one of the reasons below.

Reason 2. Incorrect transport URL

This may seem silly, but it’s worth checking it out first. In the server container URL, make sure to use the exact URL where you are running the sGTM preview to ensure the correct event data is being sent.

How to check and fix this

The straightforward solution is to send events to the correct URL or run the preview at the correct URL. It's a simple fix that can make a big difference.

Reason 3. GA4 configuration is overwritten

GA4 is most often used as a transport mechanism for transferring data from a web GTM container to a server container on the Google Cloud Platform. GCP is necessary for hosting server-side containers due to its robust infrastructure and scalability.

The problem here may be that the GA4 measurement ID you use in your tags may already be used elsewhere and re-initialized with other settings, affecting the tagging server setup on the Google Cloud Platform. It could be, for example, some plugin integrations, inline integration of gtag in code, work of another Google tag in a container, or work from another GTM container if you have several of them on your site.

How to check this

Open the network dev tool in your browser and activate the ‘preserve log’ option so you don’t lose any events when switching between pages. In the filter, specify the measurement ID of your GA4 for convenience, making it easier to find the necessary requests.

Here is an example of an event that works correctly and is sent to the URL of the server container:

And here is an event that is sent directly to GA due to configuration issues:

Check that all your GA4 events are sent to the URL of your server container, not to google-analytics.com or similar domains.

How to fix this

  • Check the code for inline code with gtag initialization or events; it usually looks something like this:
  • If you find gtag scripts in your site code, remove them altogether.Check if you have any active plugins or integrations that also send data to GA4. If so, disable these functions.
  • Ensure no other Google tags with the same measurement ID are in your container.

Ideally, use a single Google tag with GA4 configured through your GTM container.

The mechanism of the problem is quite simple. Your tag initializes gtag with the setting to send requests to the server_container_url you specify. But after that, additional config is loaded, for example, from gtag, inline code (or any other source), and initialized the same GA4 again but without server_container_url, so requests are sent directly to Google Analytics, and you don’t see anything in your server container preview.

Also, if you have this problem, you may have some of the events sent to the sGTM and some directly to analytics. It’s just that some event is sent before the Google tag config is overwritten.

Reason 4. CORS/CSP issue

Your tags' operation is blocked due to Cross-Origin Resource Sharing (CORS) or Content Security Policy (CSP) settings. 

This is a common problem with resources with advanced security.

How to check this

These problems are usually immediately visible in the browser console. Open the browser console, reload the page if necessary, and trigger the necessary events.

If you have such problems - you will see several (or many) red errors that will tell you that some request was blocked due to CSP:

Or CORS:

Any of your web tags may be blocked from working because of the same problem.

How to fix this

Contact your developers to add the necessary exceptions to the CORS or CSP rules to unblock your tags. Usually, a few screenshots of the console and a brief description of the problem are enough, but it's also worth sending them the official Google CSP documentation.

Conclusion

As a digital marketer or web developer, your role in troubleshooting these issues is crucial. When looking for problems with sending data anywhere, you should always pay attention to the browser console and the network tab. There, you can find much more information about how tags and data work than is available just in GTM preview mode. Your insights and actions are key to resolving these issues.

Tagged with:sGTM tag

Try Stape for all things server-sideright now!