What is a Data Layer? What is a Tag Management System?

“assorted-color tags” by rawpixel on Unsplash

When talking about setting up analytics tracking or website retargeting, the topic of data layer and tag management system often comes in play, but what do they do? how they they work?

When and why do you need a data layer?

Let’s take the example of a fictional website CatCo, CatCo is a website dedicated to cat pictures.It makes money by seller frame pictures of cat and has as its goal to increase its user-base 2 fold in the next 12 months. To do that CatCo wants to increase its marketing reach and performance by integrating and pushing data to as many marketing platform as possible and keeping a close look at the marketing’s performance.

CatCo however is very short staff in terms of engineers and cannot do by itself the integration to so many external system. CatCo has a problem.

Comes the data layer and tag management system. The data layer allows to set a structure for the data needed for integration with third parties website.

A Data Layer typically refers to the data object available within a browser for integration with third parties.

Let’s have a look at CatCo, CatCo wants to integrate with Google Analytics, Facebook and Bing. It doesn’t integrate with them directly but integrates with a Tag Management System that handles the integration with these systems:

How does it work?

Let’s have a look at a page on CatCo’s website:

When a user visit this page, we can see that the page has a few characteristics:

  • It relates to a page intended to sell a particular cat picture’s frame
  • It has a title and specific url
  • A specific product is being displayed on that page
  • It is possible to add a product to the cart from this page

What CatCo would be interesting in knowing and tracking from that page would normally be generated by two different types of events, page views and add to carts. If we were to decomposed the available data that could be pushed on that page for each of these events:

Let’s look at what is happening when a user called Joey goes to this page on CatCo:

Joey goes onto frame/oscar.html on his favorite browser. This initiate a request to the server, which respond with some HTML code back containing the code for the page “Oscar being petted”. The HTML code contains within it the definition of a javascript object, for instance with google tag manager it would be:

dataLayer = [{
'pageCategory': 'PDP',
'pageTitle': 'Oscar being petted',
}];

And an external script, requesting some piece of javascript code from the tag management system.

<script src="mygenerictms.com/tmsscript.js"></script>

As the page gets rendered and displayed to Joey, the script gets loaded and decides which tags need to be fired. The script also contains information related to the mapping of available data in the dataLayer object to the requested data in google analytics. This mapping is configured in the user interface of the tag management system itself. The script then fire the google analytics tag with the mapped data to triggered a page view event.

Other type of event from a page view would happen in a similar way, but the tag management script would be “listening” to specific event happening rather than doing that when the page is rendered. If Joey decided to add Oscar’s frame to his cart for instance, there would need to be an event impacting the dataLayer for the tag management script to decide if a tag needs to be fired. Google Tag Manager does that through the dataLayer.push action and Tealium Tag Manager does it through utag.link action.

What can we do with data within a dataLayer & what should be there

Data Layer provide a common way for setting up tags and front-end integration with external websites. The data within a layer can be used to setup enhanced ecommerce within google analytics, integrating with different advertising partners as well as used for other purposed within the website such as knowing when to show up a popup.

For a google google analytics website implementation there is a need to provide quite a few events and information within it’s data layer:

  • Page View
  • Add to/remove from/update cart
  • Checkout
  • Purchase

Other information may be provided in other to have a better tracking of what is happening on your website. Beside using it for tracking purpose, the information provided in the data layer is useful to feed DMPs with specific target segments. set up goals for digital marketing optimization, etc