What is dataLayer?

Also called: data layer, window.dataLayer, GTM data layer

A dataLayer push looks like this: window.dataLayer.push({ event: "purchase", ecommerce: { transaction_id: "T-1234", value: 74.50, currency: "USD", items: [...] } }). GTM sees the event name, matches it against a trigger, and passes the nested values into whichever tags that trigger fires.

The dataLayer exists so tracking does not have to scrape the DOM. Reading an order total out of a CSS selector breaks the next time a designer touches the template; reading it from a dataLayer key survives redesigns, because the contract is the key name, not the markup.

Order matters. The dataLayer must be initialised before the GTM snippet runs, or the first pushes are lost. On e-commerce platforms this is why the "add the snippet after the dataLayer block" instruction is not optional.

Why it matters

Almost every "my revenue numbers are wrong" bug traces back to the dataLayer: a missing currency, a value pushed as a string instead of a number, or a purchase event firing before the transaction ID is available.

Common questions about dataLayer

What is the difference between the dataLayer and GA4?

The dataLayer is a delivery mechanism on your own page; GA4 is a destination that stores and reports data. The dataLayer holds the raw facts, a tag manager reads them, and GA4 receives whatever the tag chose to send.

How do I check whether my dataLayer is working?

Open your browser console on the page and type dataLayer — you will see the array of pushed objects. Google Tag Manager's Preview mode shows the same data per event, with the variable values each tag actually resolved.

Should the dataLayer variable always be named dataLayer?

It can be renamed when GTM is installed, but there is rarely a reason to. Third-party plugins, e-commerce themes, and debugging tools all assume the default name, so renaming it silently breaks integrations.

Related terms

See how your site handles this

TagEasy's free auditor checks any URL for Consent Mode v2 signals, PII in tracking, duplicate pixels, and 10 other tracking-quality faults. No signup.