Raise your hand if you have ever used a Tag Management System (TMS) like Google Tag Manager and heard of the mysterious “data layer”. If you work in the digital analytics realm, more than likely you have your hand up (if you’re actually raising your hand, put it down before you get weird looks).

Well, I’m here to demystify the data layer and teach you how to find the information that is in the data layer or being pushed to it.

What’s a data layer?

A data layer is basically an object created by Google Tag Manager that holds a bunch of information. From Google Tag Manager’s Developer Guide:

“A data layer is an object that contains all of the information that you want to pass to Google Tag Manager. Information such as events or variables can be passed to Google Tag Manager via the data layer, and rules can be set up in Google Tag Manager based on the values of variables (e.g. fire a remarketing tag when purchase_total > $100) or based on the specific events. Variable values can also be passed through to other tags (e.g. pass purchase_total into the value field of a tag).”

Why use a data layer?

The data layer allows data to be collected regardless of the HTML page structure. Any changes to the HTML page structure won’t affect the data layer, which means data collection tools have an unchanged source of data to continue to access.

How do I know what’s in the data layer?

Many times, you’ll want to see what information is actually in the data layer or being pushed to it. To get information out of the data layer, you will need to build macros in Google Tag Manager that map to specific data layer variables.

For instance, I have a scroll tracking tag on my site that makes dataLayer.push’s for different scrolling events. How do I know the tag is working properly and pushing information to the data layer?

Easy. Perform whatever action should push data to the data layer and then head over to your JavaScript console (Option + Command + J on a Mac, Control + Shift + J on PC).

Type in “dataLayer” and hit enter. Voilà!

The Data Layer


Google Tag Manager creates the data layer by default. In the above screenshot, objects #1, 2, and 4 will be created by Google Tag Manager by default, in that order. Now comes the fun part.

You can see object #3 in the screenshot above includes data from my scroll tracking tag. This information was pushed to the data layer and I can now pull it out using Google Tag Manager and push it into Google Analytics. I detail how to do this to track scroll depth.

So now you know how to check the data layer and the information that is present or has been pushed to it. What are the next steps? Start using the data layer to add or compile data you want to track in Google Analytics!

Here is a great blog post from Justin Cutroni on the data layer and some use-cases: http://cutroni.com/blog/2012/05/14/make-analytics-better-with-tag-management-and-a-data-layer/

As always, let me know if you have any comments!

There are no comments.

Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>