Learn business growth with Google Analytics 4 Forums Google Analytics 4 How to Monitor GTM Server-Side Response Codes and Bodies in Log Explorer of Google Cloud? Reply To: How to Monitor GTM Server-Side Response Codes and Bodies in Log Explorer of Google Cloud?

  • Roman

    Member
    23 May 2023 at 9:22 pm

    Indeed, the response body of your requests doesn’t currently appear on Google Cloud Log Explorer as a default option. This is a standard design due to privacy and costs, regarding logging everything by default. However, you can enable body logging in some Google Cloud services like Google Cloud Functions and Cloud Run by modifying the function’s code according to the function’s documentation.

    For instance, in GTM Server-Side, if the changes you make get compiled into JavaScript and executed, you can add custom logs to your code using the “console” object. After doing this, you’ll be able to see these logs in the Log Explorer under the “textPayload” field. Keep in mind, when adding extra logs, you have to watch out for User Privacy and Google’s usage costs (always depending on the amount of data you’re logging, and how long you retain these logs).

    On the other hand, for the error catching and alerting system, Google Cloud Logging offers the option to create metrics based on the logs and then set up alerts based on these metrics in Google Cloud Monitoring.

    Remember that making these changes should be carefully done, especially when it comes to user privacy and cost management.