On this page
What a data layer is
In Google Tag Manager it is a JavaScript array called dataLayer: the site pushes small objects into it, such as the type of page, the product being viewed, or the fact that a form was just submitted, and Tag Manager uses those values to decide which tags fire and what they send.
It matters because it separates tracking from design.
Without one, tags read information off the page, a price from a heading, a confirmation from a CSS class, and the first redesign breaks them without anyone noticing. With one, the site states the facts once, in a fixed format, and every tag reads the same values.
What goes in it
A minimal push looks like this:
dataLayer.push({ event: 'generate_lead', form_name: 'quote_request' })
Before and after: reading a price
Example for illustration; not a client's data.
Designing one that lasts
Write the specification before the code: every event, every parameter, its type, and the pages where it fires. Keep the names consistent and use GA4’s where they exist. Version it, and add a check to your release process so a template change that removes a push is caught before it ships.
Single-page apps and checkouts
Sites built as single-page apps change the page without a full reload, so Tag Manager never sees a new page load. The app should push a virtual page view to the data layer on each route change, with the new path and title, and GA4’s page_view should fire from that push rather than from the page load. The same applies to multi-step checkouts and booking flows built in one page: each step should push its own event, such as begin_checkout, add_shipping_info and add_payment_info, so the funnel shows where people stop.
Data layer and consent
When a visitor makes a cookie choice, push it to the data layer as well as to your consent platform, so tags that depend on consent can read the current state. Google’s Consent Mode reads its own consent commands, but other vendors’ tags often need a trigger tied to an event like consent_updated. Test both a refusal and an acceptance in Preview mode: with consent refused, no advertising tag should fire.
How to check it yourself
- Walk through a key journey.
Open Tag Manager's Preview mode and walk through a key journey on your site.
- Read each push.
The left panel lists every data layer push in order; click each to see its values and which tags fired. Missing pushes, wrong values and events that fire twice show up immediately.
SMARTSEO doesn’t read your data layer. With Google Analytics connected it shows the visits and sales your tracking records, so a sudden gap is visible in the app.

The problems we find most often
These come from hands-on work, not from the app’s checks. Open one to see what it looks like and how to fix it.
CommonTracking scraped from the page
- What we see
- Tags read prices, product names or form results from the page's text or CSS classes.
- How to fix it
- Have the site push those values to the data layer, so a redesign can't silently break tracking.
CommonPushing before the container is ready, or resetting it
- What we see
- Some events never reach Tag Manager, or earlier values vanish after a push.
- How to fix it
- Always initialize with window.dataLayer = window.dataLayer || [] and only ever push to it; never reassign the array after the container loads.
CommonStale ecommerce data
- What we see
- A purchase event carries items from an earlier product view.
- How to fix it
- Push { ecommerce: null } before each ecommerce event to clear the previous object, as Google's ecommerce guidance recommends.
CommonNames that drift
- What we see
- The same value arrives as productPrice, price and item_price on different pages.
- How to fix it
- Write a short data layer specification, use GA4's event and parameter names where they exist, and review new pushes against it.
CommonPersonal data in the data layer
- What we see
- Email addresses, names or phone numbers are pushed in plain text and end up in analytics.
- How to fix it
- Never push personal data to analytics. Use an internal ID where you need one, and check what each tag forwards.
Questions people ask
What is a data layer in Google Tag Manager?
A JavaScript array, window.dataLayer, that your site pushes structured information into: the page type, the product, the user's action. Tag Manager reads those pushes and uses them as triggers and variables for your tags.
Do I need a data layer for GA4?
For basic page views, no. For anything that matters commercially, like purchases with their value, form submissions or logged-in states, a data layer is the reliable way to get the data to Tag Manager.
Who should own the data layer?
Developers write the pushes; whoever owns analytics writes the specification. Treat it like an API: documented, versioned and tested when the site changes.
How do I see what my data layer contains?
Type dataLayer in your browser's console on any page, or open Tag Manager's Preview mode, which shows every push and what each tag did with it.
What we do for you
- A data layer specification written for your site and your reports
- Implementation with your developers, page type by page type
- Ecommerce and form events in GA4's standard format
- Testing in Tag Manager's Preview before anything goes live