Cookie preferences

Choose which optional cookies EndFrame may use on this site. Analytics and advertising tools load only if you allow them, and you can change your mind any time from “Cookie settings” in the footer. Whatever you choose, this tab keeps the campaign labels from the link that brought you, and they are saved with your account if you sign up. Read the Cookie Policy.

Needed for the site to work, such as remembering this choice. Always on.

Lets us load analytics tools through Google Tag Manager, including Google Analytics and Microsoft Clarity session recordings, to understand how the site is used.

Allows advertising tags to measure our ad campaigns. None run on this site today. It also keeps ad click IDs from the page address for this tab, and saves them with your account if you sign up.

Skip to main content

What Is a Data Layer? A Plain-English Guide for Marketers

Developers mention the data layer whenever tracking comes up, and marketers are left nodding along. This guide explains what a data layer is in plain language, what goes in it, how Google Tag Manager uses it, and why it makes conversion tracking more reliable.

The EndFrame Team5 min read

You asked a developer to track lead form submissions, and the answer was that it depends on whether the site has a data layer. Or an agency quoted for a data layer implementation and you are not sure what you would be paying for. A data layer is a simple idea with a technical name, and once you understand it, a lot of tracking conversations become easier. This guide explains it without code you need to write yourself.

The short definition

A data layer is a structured list of facts that your website publishes for tracking tools to read. In practice it is a JavaScript array, conventionally named dataLayer, that sits on every page. When something meaningful happens, such as a page loading, a form being submitted or an order completing, the site adds a small record to that list describing it. Google Tag Manager and other tools watch the list and fire tags with those values.

Think of it as a noticeboard between your website and your marketing tools. The website pins up notices: this is a product page, this product costs 49 pounds, a lead form called demo request was just submitted. Tools read the notices instead of trying to work it out from what is on screen.

Why not just read the page?

Without a data layer, tags have to scrape the information they need from the page itself: the text inside a price element, a CSS class on a button, a word in the URL. That approach is called DOM scraping, and it is fragile.

  • A designer renames a CSS class and the purchase tag stops reading the order value.
  • A price is displayed with a currency symbol and a thousands separator, and the tag sends 1,299.00 as text instead of 1299.
  • The thank-you message is rendered by JavaScript after the tag has already looked for it.
  • The same form appears on twenty pages with different layouts, so one selector cannot find it everywhere.

A data layer separates what happened from how it looks. The developer who builds the checkout knows the order value as a number at the moment the order is placed, and publishes it. The tag reads it. Redesigns no longer break tracking because the noticeboard stays the same.

What a data layer push looks like

Google's documentation shows the pattern. The page first makes sure the array exists, then pushes objects into it. A lead form submission might push an object with an event name of generate_lead, a form_name of demo_request, and a form_location of pricing_page. A purchase might push an event of purchase plus an ecommerce object containing transaction_id, value, currency and an items list. You do not need to write this yourself, but you should agree with your developer on exactly which events and fields will be pushed, and what they will be called.

The event key is special in Google Tag Manager. When a push contains an event value, GTM treats it as something that just happened and evaluates triggers. A Custom Event trigger can listen for generate_lead, and Data Layer Variables can read form_name or value from the same push and pass them to GA4, Meta or any other tag.

What usually goes in it

Type of factExamplesTypical use
Page contextPage type, content category, language, logged-in stateSegmenting reports, choosing which tags fire
Conversion eventsgenerate_lead, sign_up, purchaseFiring conversion tags at the right moment
Conversion detailsForm name, order ID, value, currency, itemsReporting revenue and deduplicating events
User propertiesCustomer type, plan, hashed or raw email where consentedAudience building and enhanced matching

Agree on naming before anything is built. If one page pushes formName and another pushes form_name, your reports will split. Many teams reuse GA4's recommended event names, such as generate_lead and purchase, so the same structure works in GA4 without remapping, and adapt them for other platforms in the tag manager. The difference between platform event names is covered in our guide to Meta standard events and custom events.

Common mistakes

  • Overwriting the array. Code that sets dataLayer to a new array after GTM loads breaks the link between the page and the tag manager. Always add to the existing array.
  • Pushing the event before the data. If the order value arrives in a later push than the purchase event, the tag fires with no value.
  • Leftover ecommerce data. GA4's ecommerce guide recommends clearing the previous ecommerce object before pushing a new one, so values from one event do not leak into the next.
  • Pushing on click instead of on success. A lead event pushed when the submit button is clicked fires even when validation fails. Push after the server confirms the submission. Our guide to tracking form submissions reliably explains why this matters.
  • No documentation. A data layer without a written spec decays as soon as the developer who built it moves on.

Who owns it

A data layer sits between two teams. Developers build and maintain the pushes, because only the site's code knows when an order truly succeeded and what it was worth. Marketing and analytics decide what needs to be measured and what each field should be called. Problems start when neither side owns the specification. Keep a short shared document listing each event, when it fires, every field with its type and an example value, and which tags depend on it. Review it whenever a form, checkout or page template changes, and add a data layer check to the release checklist so a redesign cannot ship with silent tracking breakage.

How to check yours

  1. 1Open GTM's Preview mode and load the page. The left-hand timeline lists every data layer push in order.
  2. 2Trigger the action, such as submitting a test form, and click the new event. The Data Layer tab shows exactly what was pushed.
  3. 3Confirm the event name, the field names and the value types match your spec: numbers as numbers, not text.
  4. 4Check the destination. In GA4, DebugView shows whether the event and its parameters arrived as expected.

The data layer and server-side tracking

A data layer lives in the browser, so it inherits the browser's limits: ad blockers and consent choices can stop the tags that read it. It is still the best place to define clean events, and server-side setups often start from the same events. The browser publishes a lead or purchase once, and a first-party collector or server container forwards it to each platform. Our comparison of server-side and client-side tracking explains how the two fit together.

Where EndFrame fits

EndFrame's tracker records page views, form submissions and conversions on its own, so you can start without a full data layer project. Where you already have clean data layer events for purchases or leads, they make good conversion definitions, and EndFrame can deliver those conversions server-side to Meta, GA4 and TikTok with a shared event ID. Whether or not you use a tool, a short written data layer spec is one of the cheapest reliability improvements a marketing team can make.

Frequently asked questions

Do I need a data layer if I use Google Tag Manager?

GTM creates a dataLayer array automatically, so in a sense you always have one. The question is whether your site pushes useful information into it. Without that, your tags fall back on reading clicks, CSS selectors and page URLs, which work until someone changes the page. For anything involving revenue or leads, a proper data layer is worth the developer time.

Is the data layer the same as a database?

No. A data layer lives only in the visitor's browser for the life of the page. It holds a few facts about the current page and what the visitor just did, then disappears when they navigate away. Nothing is stored permanently unless a tag reads it and sends it somewhere.

Can I put personal data such as email addresses in the data layer?

You can technically, but be careful. Anything in the data layer is readable by every script on the page, including third-party tags. If you need an email for enhanced matching, expose it only on the pages and events that require it, and make sure the tags that read it are covered by your consent setup and privacy notice.

Try EndFrame

Add a server-side path for your conversions.

EndFrame collects events first-party and forwards conversions server-side to Meta, GA4, TikTok, and webhooks with event-ID deduplication — then credits each conversion to its campaign, with the visit-to-conversion path you can audit.

No credit card required

Keep reading