Debugging server-side tracking can be challenging but essential for ensuring precise server-side tracking. The process of debugging server-side tracking includes several key elements.
Firstly, monitoring of the cloud server infrastructure that hosts your server-side Google Tag Manager container. If you are using Stape, our team handles this for you.
The second aspect involves ensuring the accuracy of your tracking setup. Since server-side tracking via sGTM can be implemented in various ways, the tools and methods for debugging and monitoring are also different.
This blog post will discuss several methods for debugging and monitoring the server-side tracking.
The sGTM Debugger helps debug and analyze server Google Tag Manager implementations (understanding how tags, triggers, and variables work within GTM).
One of the standout features of the sGTM Debugger is its user-friendly interface. Even those with limited technical expertise can easily navigate through the data streams. The tool ensures comprehensive coverage of all potential tracking issues, from identifying missing or erroneous data to validating trigger setups. Let’s talk about each component of the sGTM preview.
It shows all the details about the requests and events. These requests usually come from the web GTM container and are transported to the server side. However, several ways of delivering server data to the sGTM container exist.
To see the details of each request, simply click on it. The rest of the information should be checked in other tabs.
There are three main components in this tab:
If the response code for the outgoing request is not 200, meaning there were some issues with processing the request, you can check the response body and read which error exactly stopped the request from processing.
Shows all the tags fired for each incoming event request. If you click on the tag, it will show you all the data the tag uses.
You can see all the variables you have created and their values for the corresponding event.
Whenever the client claims the requests in the sGTM container, it converts request data to event data. Then, you can use event data to configure variables. If we compare it to a web GTM container, event data is like a data layer of an sGTM container.
Shows all errors that happened in this request (if any). It consists of the error detail and the source that caused the error.
Logs allow you to monitor sent data, response codes, and processed parameters, ensuring no network or vendor issues are missed.
We offer log access to users on Pro and Business plans. Users on Pro and Pro+ plans can access logs for the past three days, while those on Business plans or higher have a 10-day log access window.
There are four types of logs:
Access logs are available by default, while request and response logs exist only for tags created by stape. To see request and response logs, they must be activated in the tag settings. This is done by opening the sGTM tag, scrolling to Logs Settings, and enabling the 'Always log to console' option.
There are multiple use cases on how stape logs can be used. For instance, you can verify if any events were sent to Facebook that were not processed successfully, meaning that the status code was not 200.
To do so, enable logging of the Facebook tag, as shown in the screenshot above. After collecting request data, open response logs in stape admin and select client and response code. In my case, I’m checking Facebook and 4xx responses.
Several events have 400 status. You can click on a row on the right side of each log and see a sequence of access to response logs and troubleshooting in which 400 responses were received.
The easiest way is to find the response body and check its message. In my case, the event wasn’t processed because the parameter was missing.
"ResponseBody": "{"error":{"message": "Invalid parameter," "type": "OAuthException," "code":100, "error_subcode":2804019, "is_transient": false,"error_user_title": "Server Side API Parameter Error," "error_user_msg": "The parameter $['data'][0]['event_name'] is required.","fbtrace_id": "xxxxxxx"}}"
Logger tag for server Google Tag Manager is beneficial for testing POST requests in sGTM. The body of POST requests is not automatically included in logs for Google Cloud or Stape. To access detailed information about POST requests, you should utilize the Logger Tag and activate the 'Log Request Body' option within the tag's settings.
Add if from the sGTM tag template gallery to use the Logger tag. Select if you want to log events only while debugging or always -> Select what information you want to add to logs -> add event name. You can use either static or dynamic name -> add custom data if needed -> add a trigger.
Once the tag is triggered, go to your sGTM Container -> click logs -> other logs -> add event name -> apply filter.
You will see information about requests and can troubleshoot any issues.
You can learn more about our Logger tag in the article here.
The sGTM Preview header configuration is a power-up available for all Stape users. It's handy for viewing requests in the sGTM debugger when sending them to sGTM from outside the Web GTM. For example, you can debug webhooks sent to your sGTM container.
To use this power-up, open sGTM's preview mode (“Preview” in the top right of your workspace). Then, in the top right corner, click on the three dots, select 'send request manually,' and copy the preview header.
Next, insert this header into your Stape container settings.
To retrieve webhook requests in sGTM, add a Data Client to your sGTM container and create a Client with the type Data Client. Scroll down to the accepted path setting and add a path to which the webhook was sent. We have a detailed guide on how to use webhook in sGTM. Learn more about it by clicking this link.
Remember, the preview header changes dynamically. Therefore, removing it from your stape.io account after completing your tests is crucial to ensure future requests are visible in the sGTM debugger. If you did not turn off the sGTM Preview header config, stape will automatically turn it off in 30 minutes.
The monitoring feature is helpful for ongoing monitoring of your server GTM container work and the correct excursion of tags. It allows you to set rules that will send email notifications or Slack notifications when the rule is triggered. For example, you can receive a notification when the number of purchases sent in GA4 equals 0.
Imagine you are checking your Facebook campaign results, and suddenly you discover that despite spending your entire budget, you've recorded zero conversions for several days :(
Often, this is due to an oversight during your site update, like removing a GTM snippet or disrupting the purchase event data layer.
These minor errors can cost an arm and a leg, as they hinder ad optimization and obscure the true ROAS of your campaigns. At Stape, we've experienced these challenges firsthand, so we've introduced a Monitoring feature to help reduce the impact of such issues. It is available to all Stape sGTM hosting users with Business, Enterprise, and Custom plans.
You can create, edit, or delete your container monitoring notifications. To do so, open the sGTM container and click on the Monitoring tab. If you already have some rules configured, you will see the list of rules in this tab, whether they were triggered, the number of times they were detected, and the last detected time.
Below is an example of the monitoring rule that sends a notification when GA4 has less than one lead event triggered in the last 12 hours.
Monitoring alerts work based on the container logs:
The notification settings include:
You can find the configuration examples and more information on our feature Monitoring in this article.
To wrap up, knowing how to debug server-side tracking is critical for reliable and accurate data. This guide has shown you tools like the sGTM Debugger, Stape Logs, Logger Tag, Preview Header, and Monitoring.
Each tool helps find and fix tracking errors. Good debugging isn't just about solving problems now; it's about constantly monitoring which data is received and sent to each vendor and checking the setup when data does not look correct.
We hope this guide has made you more skilled in server-side tagging debugging, making your data gathering solid and meaningful. Keep exploring and let your data lead you to more tremendous success in digital analytics and marketing.
Don't worry, we've got you covered! Click on Get assistance and we will send you a free quote.