AudienceView Connect

Use Case Three (GTM) – Sending Errors as Google Analytics Events

nderstanding what errors your visitors are receiving on your website can provide valuable insights into their online journey. Every time a visitor receives an error in the online that error is recorded in the dataLayer. In the dataLayer terminology, an error is an event. We can send those events into Google Analytics and report on their occurrences.

In this use case we will send errors as events to Google Analytics when a user receives an error on the best available seat selection page. You can choose to send all visitor errors to Google Analytics, but in this example we will just focus on a single page. This particular use case could have a business objective of trying to understand when your visitors are starting to receive errors that they cannot get their seat selections due to low availability.

Using-Google-Analytics-to-Confirm-that-the-Data-is-Received.jpg

Implementation

The video below demonstrates the steps required to complete this use case. Please watch the video in conjunction with the documentation.



Before creating your tag to track events you should spend some time thinking about your Google Analytics event naming convention and strategy. Google Analytics’ events have a Category, Action, Label and Value. If you are going to track lots of events in Google Analytics you should think about creating a consistent naming convention strategy for those events. Refer to the Google Analytics documentation for more information about these attributes of events. Google Tag Manager will prompt you to enter values for each of these attributes although some are optional. For this example, we will call the category of our event ‘User Interaction’, the action ‘Error Occurred’ and the label will contain the actual error message.
top

Required Variables

First, we need to create a variable that grabs the error details from the dataLayer. The dataLayer contains six pieces of information about the error:
  1. The error context
  2. The error message
  3. The error method
  4. The error number
  5. The error severity
  6. The error type
In this use case we are only interested in the error message received by the visitor. For other scenarios you may choose to use the other fields. For other types of analysis you may need to request some of the others fields; therefore, it is good practice to inspect the dataLayer for the particular error that you are trying to analyse and confirm whether you need any additional fields. The troubleshooting and best practices guide describes how to inspect the dataLayer.

Let’s create a variable that reports the error message that the visitor received:
  1. Choose the option to create a new variable.
  2. Set the 'Variable Type' to Data Layer Variable.
  3. Set the 'Data Layer Variable Name' to event.av.event.error.message.
  4. Set the 'Data Layer Version' to Version 2.
  5. Leave the ' Default Value' blank.
  6. Save the variable.
top

Required Triggers

This use case requires us to create a trigger that has two conditions. The tag will only fire when both conditions of our trigger are met. Our two conditions are:
  1. The tag must fire only on the best available seat selection page.
  2. The tag must only fire when the visitor receives an error event on the page.
We can identify the page through the URL, fortunately Google Tag Manager already provides a variable to grab that data. For the event, the dataLayer will contain an event of av.event.error whenever a visitor receives an error. Google Tag Manager also provides a variable to capture events on the page.
  1. Choose the option to create a new trigger.
  2. Add a condition for {{url}} contains seatSelect.
  3. Click the plus symbol and add another condition for {{event}} equals av.event.error.
  4. Save the trigger.
top

Configuring the Tag

  1. Choose the option to create a new tag.
  2. Give the tag a name.
  3. Choose the Google Analytics – Universal Google Analytics tag type.
  4. Enter your 'Web Property ID' (you get this from your Google Analytics account).
  5. Set the 'Track Type' to Event.
  6. Set the 'Category' to User Interaction.
  7. Set the 'Action' to Error Occurred.
  8. Choose the variable you created for the error message to be the 'Label'.
  9. Add a 'Firing Trigger' and select the trigger that you created in the Required Triggers section above.
  10. Save the tag.
  11. Use the preview and debug mode to confirm that your tag is firing.
  12. Use Google Analytics to confirm that the data is received.
  13. If everything is working correctly, publish the changes to your container.
top

Using Google Analytics to Confirm that the Data is Received

Most reporting in Google Analytics is time delayed. Your data will be sent to Google Analytics instantly, but this data goes through a processing stage and it can sometimes be a few hours before you see the data in your reports.

Fortunately, some data is available in real-time and that data includes event reporting so we can see in real-time the errors that visitors are receiving on our best available page. In the screenshot below we can see that one active visitor has received an error that no seats were found for their selection. If there were hundreds of visitors receiving this error it could be an indication that something is wrong with your event configuration or that it is close to selling out (perhaps time to release some more seats).

Summary

We created a Google Analytics event tracking tag that fired only when the URL of the page contained seatSelect and an error event was created on the page in the dataLayer. We set the label of the event to the actual error message and used real-time Google Analytics reporting to view errors received in real-time on our Best Available seat selection page.