What is a data layer?
A data layer is a structured object on your web page that holds information about the page, the visitor, and their actions. Tag managers and other tools read from it, so tracking depends less on how the page is built or styled.
Last reviewed .
How a data layer works
Your site pushes details into the data layer as things happen, such as a product viewed or a purchase made. The details can include the item, price, order ID, and more.
A tag manager listens for those pushes. It uses them to fire tags and pass values to analytics and ad platforms.
Why it beats scraping the page
Without a data layer, tags often read information from page elements like text or button names. A design change can then break tracking without warning.
A data layer separates the data from the page's appearance, so tracking stays steady when the design changes.
Planning your data layer
Decide which events and values you need before development starts. Document the names and formats, and keep them consistent across pages so every tool receives clean data.
Common questions
Do I need a data layer for Google Tag Manager?
Not for basic setups, since the container can read page elements. For ecommerce and detailed event tracking, a data layer is the more reliable approach.
Who sets up the data layer?
Usually a developer adds the code, guided by a plan from the marketing or analytics team that lists the events and values needed.
Is the data layer visible to visitors?
It lives in the page's code and can be inspected by anyone with browser tools. Don't place sensitive information in it.
What goes in a data layer?
Page details, user status, and event information such as product views, cart actions, and purchases, along with values like price and order ID.
Want help putting this to work?
Tell us where your marketing stands today, and we'll show you what to do first.