Free auditStart free
GlossaryGlossary · Measurement

Data layer

The data layer is a JavaScript array that passes page information to Google Tag Manager. How push works, the event key, common mistakes and a console check.

2 min
read
1
sources
Oct 29, 2026
updated
Scaplet Editorial Team
author
In one line

The data layer is a JavaScript array, window.dataLayer, that holds information passed from your site to Google Tag Manager or gtag.js. Tags can fire on events you push or on variable values you set, so the page and the tags stay decoupled.

30-second check

Is this costing your site traffic?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode

At a glance

5 facts from the sources below
window.dataLayer (an array)
Object
dataLayer.push({...})
Add data
event
Event key
Case-sensitive
Case
One data layer
Per page
02At a glance

Rules that cause most bugs

Rule

Never overwrite or re-assign window.dataLayer

What goes wrong if you break it
Google says not to do it, because reassigning replaces the array the container reads
Rule

dataLayer is case-sensitive

What goes wrong if you break it
datalayer.push fails
Rule

Quote variable names

What goes wrong if you break it
Unquoted names break the push
Rule

Variables last for the current page only

What goes wrong if you break it
Push again on each page load
Rule

Push above the container snippet to have data when the container loads

What goes wrong if you break it
Later pushes arrive after the container has loaded
Rule

Use one data layer per page

What goes wrong if you break it
Google's guidance is one data layer per page
03Your call

Data layer or tag settings?

If this fits

Use the data layer when

  • The value exists in page code or your backend, such as plan or logged-in status
  • Several tags need the same value
  • You want to rename a front-end element without breaking tracking
Or

Skip it when

  • The value is already in the URL or a cookie and a built-in variable reads it
  • One tag needs a fixed value you can type into the tag
04Check it

Check it in 2 minutes

Open DevTools on a page with a container, go to the Console and read the array. It should list the entries your page and container have pushed, in order.

If window.dataLayer is undefined, the array was never declared or the container is not on that page.

Console check
window.dataLayer
// then push a test event and watch it in GTM Preview:
window.dataLayer.push({ event: 'console_test' });
Questions

Asked a lot.

2 questions people ask next, answered from the sources on this page.

01What is the difference between the data layer and Google Tag Manager?

The data layer is the array that holds your data. Tag Manager is the container that reads it and fires tags.

02Can I rename the data layer?

Yes. Google says you can rename it by changing the snippet parameter, and for gtag.js by adding the l query parameter.

Sources · 1

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • google.com
  1. 01The data layerdevelopers.google.com · checked 2026-11-01
Free · 2 minutes

Know the term. Now check your site.

The free audit reads robots.txt, sitemaps, status codes, canonicals, redirects and structured data.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • +212% organic clicks in 90 days Ledgerly