dataLayer.push is the line of JavaScript a website uses to hand information to Google Tag Manager: that a form was sent, which product was added to the basket, or what an order was worth. Each push adds a small message to the data layer, and Tag Manager reads those messages to decide which tags to fire and what to send.
How dataLayer.push works
The data layer is a list that lives in the page. Tag Manager watches it. When the site calls dataLayer.push with an object, such as event set to quote_request and service set to boiler_repair, Tag Manager receives that message straight away.
Two parts of a push do different jobs:
- The event key is the name of what happened. A custom event trigger in Tag Manager listens for that exact name and fires tags when it arrives.
- The other keys are details. Data layer variables in Tag Manager read them, so a GA4 tag can send the service name, form name or order value as event parameters.
A push without an event key still stores its details, but no trigger fires on it. That suits information you want available later, such as a page type or a logged-in status set before Tag Manager loads.
The data layer should be declared before the Tag Manager snippet with the familiar “window.dataLayer = window.dataLayer || []” line. That line creates the list only if it does not exist yet, so pushes made earlier are kept rather than wiped.
Why it matters
Tracking that relies on clicks and page structure breaks whenever a developer renames a button or redesigns a form. A push from the site’s own code says plainly what happened, so it survives redesigns and gives cleaner data. It is the difference between guessing that a click on a blue button probably meant a booking and being told that a booking for a 30-minute consultation was confirmed.
For shops, ecommerce events such as add_to_cart and purchase are almost always passed this way, with the product details in an ecommerce object. Google recommends pushing ecommerce set to null just before each new ecommerce push, so details from one event do not leak into the next.
Common mistakes
- Resetting the list with “dataLayer = []” after Tag Manager has loaded, which breaks the connection and silently stops tags firing.
- Getting the name wrong. JavaScript is case-sensitive, so “datalayer.push” or “DataLayer.push” will not reach Tag Manager.
- Mismatched event names between the developer’s code and the Tag Manager trigger, such as form_submit in one and formSubmit in the other.
- Personal data in the push. Email addresses, phone numbers or names should not be pushed for analytics. Under UK GDPR that is personal data you would then be sending on, and GA4’s terms forbid it.
- Pushing before the page knows the answer, for example sending a form event on submit before the server has confirmed it went through.
How to act on it
Agree a short specification with your developer: each event name, when it fires and which keys it carries. A measurement plan is the natural home for it. Keep names lower case with underscores, and match GA4’s recommended event names where one exists.
Test with Tag Manager’s preview mode. Every push appears in the left-hand list, and you can open each one to see its keys and which tags fired. If a push is there and a tag did not fire, the trigger is wrong; if the push is missing, the site code is.
Specifying and testing the data layer is part of setting up tracking in my performance marketing work, because paid campaigns are only as good as the events they optimise towards.
