The Blog

The Google Tag Manager DataLayer Explained

DataLayers

Anyone looking to expand the depth of their web analytic collection using Google Tag Manager has more than likely come across detailed technical implementation documents singing praise and touting that anyone who’s anyone is leveraging this awesome functionality.  I myself have sung its praises in my CPTA speaking engagement adventures and to clients.  The general vibe I get is that people know they should be using it, but no one seems to know how, or more importantly why.

What is it – an analogy

First and foremost, let’s start with an analogy to explain what exactly a data layer is.  I want you to imagine you’re in charge of a restaurant, which is your website.  Like any other restaurant you have customers, or visitors, that come in and order food off the menu.  Each plate of food represents a page on your website.  Each plate of food is made up of a few things like mashed potatoes, corn, or meatloaf just like a page on your website has buttons, polls, links, and content.  Serving up those plates of food is your wait staff who runs into the back to grab everything and serve it up to the customers just like server side code on a website does with a database. Now in this restaurant you frequently have customers coming in, asking for the same food as the other patrons, and leaving.  To expedite this you create a buffet, or data layer.  Whenever the wait staff runs into the back to get a plate for a customer you tell them to also grab a plate for the buffet.  Someone orders mashed potatoes the waiter will give some to the customer, and then put some out in the buffet.  The datalayer is simply making data available for another application to take as needed.

Why it’s cool

If you were to use a datalayer outside of GTM, you would have to manually build out that functionality to your site.  Some other web applications have this functionality so it’s case by case.  GTM is natively stocked with the ability to push items to the data layer.  If you’re using a GTM container on your site then you can leverage the datalayer code.  This pre-packaged functionality saves development a lot of time and effort on creating.  A single line of code can push important values to the data layer.  This code can be executed on your site, or you can even use a custom HTML GTM tag to push things into the data layer.  It’s super cool because its significantly easier than it has been in the past.  Less effort with bigger results.

Why you should care

Usage of the data layer will greatly customize the reports you see in whatever reporting platform you’re sending data to in GTM.  Anything and everything served up on a page can be served up to the data layer.  Let’s say for example you’re sending data to a Universal Analytics account.  UA has the ability to create custom dimensions and populate those with custom metrics.  You could use the data layer to push what type of member someone is to these dimensions after they log in or you could push the category of a blog page.  The datalayer is also leveraged to inform GTM when something happens.  This is a critical part for event management.  Think back to the buffet analogy.  Every time a server puts steak in the buffet, everyone who loves steak comes to your buffet and grabs some. I hope this gives some clarity to what the data layer is and how it fits into the process of GTM.  Granted this is a simplified view, there really is a lot of depth to this feature I have not covered.  Conceptually try to think of the data layer as a big buffet for GTM or other third party web applications.  Ask yourself, what information on this page do I want to see in my reports?  That’s the data you push into the data layer.

This entry was posted in Technology, Google Analytics 301, Google Tag Manager and tagged , , , . Bookmark the permalink.
  • Simon Burton

    Or you could just choose a simple data capture solution such as Celebrus Technologies, which with a single line of JavaScript code and some JavaScript magic underneath, can literally capture each and every interaction with each and every object and element in a web page or web based application. There is no tagging or tag management required, no thinking ahead about what you need to collect, no custom dimensions, you just collect it all in real-time and feed the collected data into multiple applications in parallel.

  • Rubens A M Santos

    There is a point that I didn´t see clearly explained anywhere. If you feed the dataLayer with an information that comes directly from your server-side logic, GTM will use it easely.

    But if you also need that information in another point of your javascript (outside GTM), then you´ll need to instal a new library to access it. Or your server-side logic needs to feed a javascript variable too (besides de dataLayer).

    https://github.com/google/data-layer-helper#why-do-we-need-a-library
    “This project provides the ability to listen for dataLayer messages and to read the key/value pairs that have been set by all the previous messages.”
    https://www.youtube.com/watch?v=EIph_lai3xc


Cardinal Path Training

Copyright © 2014, All Rights Reserved. Privacy and Copyright Policies.