TapCub is live — analytics, insights and live chat, free on one platform
Glossary

What is a data layer? Website data layer explained with an example

A data layer is a structured object on your website that holds facts about the page, user and actions, such as an order total, for tags and analytics to read. A sample, why it beats scraping the page, and naming rules.

Chen Yu Reviewed by Oliver Reed Also called dataLayer Last updated Nov 4, 2026 Glossary

Quick answer

In web analytics, a data layer is a JavaScript object or array on the page, such as window.dataLayer, where the site writes structured facts about the page, the visitor and their actions so tag managers and analytics tools can read them without scraping the HTML.

What is a data layer?

On a website, a data layer is a structured object where the site writes the facts that marketing and analytics tags need: what kind of page this is, which product, what the order was worth, whether the visitor is logged in. Tags read the data layer instead of digging values out of the HTML.

The term means other things elsewhere (the "data link layer" in networking, a data access layer in software). This page is about the website sense used with tag managers.

A sample purchase push

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  event: 'purchase',
  order_id: 'A10234',
  value: 128.50,
  currency: 'USD',
  items: [{ item_id: 'SKU-17', quantity: 2, price: 64.25 }]
});

Sample values. The checkout page pushes this once the order is confirmed. Every tag that cares about purchases (analytics, ad conversions) reads the same values.

Why it beats scraping the page

Reading the pageReading the data layer
Breaks when text or classes changeStable contract between teams
Price may include currency symbols and formattingClean numbers and codes
Each tag parses the page its own wayOne source, same values for every tool

Naming rules

  • One event name per action, in snake_case, documented in your tracking plan.
  • Numbers as numbers, currencies as ISO codes.
  • Push after the action succeeds, not on the button click.
  • No personal data: no emails, names, phone numbers or free text.

Passing values to analytics

Analytics does not need a tag manager to use the same facts. On the confirmation page, read the values you need and send them as event properties, for example tapcub.track('purchase', { order_id, value, currency }); better still, send purchases from your server so blocked scripts do not lose them. Installing TapCub through a tag manager is covered in install with Google Tag Manager.

Was this explanation clear?

We use your answers to fix and expand this page.

Chen Yu

Technical Engineer

Focuses on tracking code, SDKs, and API integrations, with practical guidance on implementation checks and troubleshooting.

FAQ

Questions people ask

Short answers to the follow-up questions that come up most.

Still have a question?

Chat with the team behind TapCub — we usually reply within a few hours on business days.

What is the data layer in Google Tag Manager?

An array called window.dataLayer. The site pushes objects into it (an event name and values), and the tag manager listens for those pushes to fire tags and fill variables.

Why use a data layer instead of reading the page?

Page text and CSS classes change with every redesign. A data layer is a contract between developers and analytics that stays stable when the design changes.

What should go into a data layer?

Facts tags need: page type, product IDs and prices, order totals, logged-in state as a yes/no, plan type. Never put passwords, emails or other personal data in it.

Do I need a tag manager to use a data layer?

No. Any script on the page can read it, including an analytics snippet that sends selected values as event properties.

See this number on your own site

Add one script tag for web and apps, and the first reports fill in within minutes.

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics