What Is the dataLayer in Tag Management?
The dataLayer is a JavaScript array that a website pushes structured event data into, acting as a message queue between the site's code and a tag management system such as Google Tag Manager.
Each push — typically an object with an event name and related parameters, such as a purchase with its items and value — is read by GTM's triggers and variables, which decide which tags to fire and what data to pass them. It decouples the site's code from the tags themselves, so tracking logic can change in GTM without editing the site's source code.
- Data Layer Variables
- ecommerce.valueecommerce.transaction_id
Daniil Maximkin Published Reviewed
- In practice
How does the dataLayer work in practice?
A page — or a Shopify theme, or a checkout script — executes
window.dataLayer.push({...})at the moment something worth tracking happens: a page view, an add-to-cart click, a completed purchase.GTM’s container, loaded on the page, listens for these pushes via its Custom Event trigger type and matching Data Layer Variables that pull specific fields, such as
ecommerce.valueorecommerce.transaction_id, out of the pushed object. Because the dataLayer is a JavaScript array in the page’s global scope, any tag, script, or GTM container on the page can read from it, which is what makes it a shared, structured interface rather than a one-off variable. - Not to be confused with
The dataLayer is not GTM itself, and pushing to it does not automatically send data anywhere — it only makes data available for GTM, or any other listener, to pick up if a trigger is configured to react to it.
It’s also not a single universal format: ecommerce dataLayer pushes commonly follow Google’s Enhanced Ecommerce / GA4 ecommerce object structure, but a site can push arbitrary object shapes, and mismatches between what a site pushes and what GTM’s variables expect to read are a common source of tags firing with missing or blank data.
- Where to check
How to check
In the browser console on any page, typing
dataLayerreturns the current array and every object pushed so far, which is the fastest way to confirm whether an expected event fired and what data it carried. GTM’s own Preview mode shows each dataLayer push in the summary panel alongside which tags, triggers, and variables reacted to it.