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.