AudienceView Connect
AudienceView Documentation

Before We Go Any Further – We Need to Talk About the dataLayer

Let’s imagine that we own a hotel on a beautiful secluded island. We have 1,000 visitors to a beach resort. They all stay for different periods of time. We ask each visitor to create a scrapbook of their holiday. A little while later we collect the 1,000 scrapbooks and sit down to do some analysis. We want to know how many people saw the advertisement that we placed in the hotel lobby for our coastline bus tour and how many signed up for it.

Now we have a bit of a problem. We did not ask our visitors to record their visit in any particular way; each scrapbook is just a jumble of information. Some visitors may have organized that contents how they prefer and some visitors may have not organized the contents at all. It is next to impossible to perform any analysis on random pictures, notes and descriptions of things that happened.

A visitor to your AudienceView website will go through a set of experiences as they navigate your website. They will look at some content and may completed orders or cause errors. All of this information is contained within the raw code of the website; it is not exposed to you in any consistent or easy to understand way. While it is certainly possible to use Google Tag Manager to fire tags based on this unstructured view, the process of understanding the information will be time consuming or some pieces of information will not be available when you need them.

This is where a dataLayer comes in. A dataLayer describes interesting things on the page or interesting things that happen on the page in a consistent and easily consumable way. By consumable, we mean an analytics tool can use the data for analytical purposes because the data will always be described the same way. Likewise a tag management tool can be configured to fire a tag when the visitor completes an order because it will always be described the same way. By interesting, we mean that they may be of interest to you for use in your analytics reporting. Generally things of interest will be attributes of the visitor or pages that the visitor sees, and the things that the visitor purchased. You can use these within tags to improve your marketing.

Not to get too technical, you can think of a dataLayer as some consistent descriptions that we add to the bottom of every page viewed by the visitor. We keep updating those descriptions as the visitor moves through the website. We describe these things with a number of objects that are output on the page but not visible to the visitor. The trick is that these objects are visible to Google Tag Manager and subsequently can be used in tags.

Let’s take a quick look at these objects without getting too technical at this point. If you want to get technical you should jump over to the technical appendix where the dataLayer is described in more detail.

There are five objects included in the dataLayer:
  1. av.session: This object describes attributes of the visitors’ session. We describe attributes like the visitors’ language selection, their current role and the referrer that was passed in the URL.
  2. av.page: This object describes the URL of the current page, what articles visitors are seeing on the page, what they searched for and some attributes of the results of that search.
  3. av.cart: This is created when visitors start an order, and it is always kept in sync with the current state of the order (i.e. we remove a performance when the visitor removes a performance). It describes all of the details of the products that visitors have their orders.
  4. av.order: This object is created when visitors create an order. It is almost identical to av.cart but it has a few more attributes available, like order numbers, delivery methods, payment methods and some customer details that were saved on the orders.
  5. transaction: Like av.order it describes the order but it describes it the exact way that Google wants us to describe it. This object exists to provide ecommerce transaction reporting to Google Analytics (once you deploy a Google Analytics ecommerce tag). It contains a lot less detail than av.order.

Events are created in the dataLayer as they happen on the page. There are three events described in the dataLayer:
  • av.event.error: This describes the error number and the full details of the error.
  • av.event.order-created: This event occurs when an order is completed. It has no other attributes.
  • av.event.order-loaded: This event occurs when an online visitor views a previous order.

This event exists because we use the same page online when an order is created or when a previous order is viewed. These events allow you to differentiate between the two visitor journeys.

Did you notice what the dataLayer is describing? We described what visitors saw, what errors occurred, what they added to the shopping cart, when they created orders and what that orders contained. The goal of our implementation of the dataLayer is to describe the sales funnel in as much detail as possible. Let us know if there is something missing from the dataLayer that you wanted to use within Google Tag Manager. We will add it to a feature list to consider for inclusion at a later date..