# Data layer

Category: [Analytics & Measurement](https://seo-geo-glossary.com/en/glossary/category/analytics-measurement/) › [Tracking & consent](https://seo-geo-glossary.com/en/glossary/category/analytics-measurement/tracking-consent/) · Also known as: dataLayer

A **data layer** is a JavaScript object on a website that holds information about the page and user interactions so that tags can read it. In Google Tag Manager and gtag.js it is an array called `dataLayer`, and the site adds data to it with `dataLayer.push()`.

## How does the data layer work?

The site pushes key-value pairs into the array, such as a page type, a product ID, or a login state. Tag Manager reads these values as data layer variables and can use them in tags and triggers. A push that contains the key `event` can fire a trigger.

Google documents that Tag Manager processes messages first-in, first-out, one at a time in the order they arrive. Values persist only while the visitor stays on the current page, so anything needed on every page has to be pushed again on each page load. Variables that should be available when the container loads belong above the container snippet.

For SEO teams, the data layer is often where analytics gets page types or conversion data for organic traffic (assessment).

## Example

```html
<script>
  window.dataLayer = window.dataLayer || [];
  window.dataLayer.push({
    'pageType': 'product',
    'event': 'view_item'
  });
</script>
```

The first line reuses an existing `dataLayer` array instead of replacing it.

## Common mistakes

- **Assigning instead of pushing.** `dataLayer = [...]` overwrites values that are already there.
- **Wrong capitalization.** The object name is case-sensitive, so `datalayer` is a different variable.
- **Unquoted keys.** Google asks for variable names in quotes, for example `'new-variable'`.
- **Inconsistent names.** The same information should use the same variable name on every page.

## Related terms

- [Google Tag Manager](https://seo-geo-glossary.com/en/glossary/google-tag-manager/index.md)
- [Tracking](https://seo-geo-glossary.com/en/glossary/tracking/index.md)
- [Web analytics](https://seo-geo-glossary.com/en/glossary/web-analytics/index.md)
- [Google Analytics 4 (GA4)](https://seo-geo-glossary.com/en/glossary/google-analytics-4/index.md)
- [Event tracking](https://seo-geo-glossary.com/en/glossary/event-tracking/index.md)

## Sources

- [The data layer – Google Tag Manager, Google for Developers](https://developers.google.com/tag-platform/tag-manager/datalayer)

---

Last updated: October 7, 2026
URL: https://seo-geo-glossary.com/en/glossary/data-layer/
