Skip to content
Google Tag Manager

What Is the dataLayer in Tag Management?

Definition

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

  1. 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.value or ecommerce.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.

  2. 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.

  3. Where to check

    How to check

    In the browser console on any page, typing dataLayer returns 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.

Daniil Maximkin

Hi, I’m Daniil.

I work with you from defining the problem to implementation and handover. You talk to the person who does the work. I work in English and Russian.

What do you need to get working?

Describe your task

The first answer is free, within one working day. Or write directly: next@taskfordaniel.com