Data layer
A data layer is a JavaScript object on a website that holds structured information about the page and user actions, which tag management tools read to send accurate data to analytics.
The data layer is a bridge between your website and your tracking tools. Instead of scraping values from the page’s design, tags read clean data from one place.
In more detail
In Google Tag Manager setups, the data layer is an array called dataLayer. The site pushes events and values into it, such as dataLayer.push({event: 'generate_lead', form: 'contact'}) or ecommerce details like product IDs and prices. GTM triggers listen for those events and tags send the values on. Documenting the data layer’s events and fields helps developers and marketers stay aligned.
Why it matters
A data layer makes tracking reliable and resilient to design changes. Without it, a simple redesign can silently break analytics.
An online store's purchase tracking breaks every time the checkout design changes. Moving to a documented data layer push on order confirmation keeps tracking stable through redesigns.