Data layer
A data layer is a JavaScript object, usually an array called dataLayer, that your site pushes structured events into so tags can read them consistently.
What is a data layer?
A data layer is a structured place on the page where your site describes what's happening, separate from the HTML. In Google Tag Manager it's a JavaScript array named window.dataLayer. Your code pushes objects into it, such as an event name and its details, and tags read from it.
The point is decoupling. Developers describe the event once, in a stable format, and marketing tags pick out what they need without scraping the page or depending on CSS selectors that change with every redesign.
What goes into it
A typical e-commerce data layer covers events like page_view, view_item, add_to_cart, begin_checkout and purchase. A purchase push carries the transaction id, value, currency and the items bought. Some sites also push user details, such as a logged-in user's id or hashed email.
Google's GA4 e-commerce event names have become a de facto standard, so many tools understand them out of the box.
Common data layer problems
Order of operations is the biggest one. A tag that reads the data layer before the purchase is pushed sees nothing, or sees a value of zero, which quietly corrupts revenue reporting. Inconsistent naming across pages, values sent as strings instead of numbers, and pushes that only happen on full page loads in single-page apps are also common.
These bugs rarely throw errors. The tag fires, the platform accepts the event, and the data is wrong.
How TracerKit handles it
TracerKit uses window.tracerkitLayer, a plain array with GTM-dataLayer-compatible push semantics and a typed e-commerce spec. Pushes made before the loader boots are processed on boot. TracerKit uses these events for triggers, verification and server-side forwarding.
See how TracerKit handles this: Data layer spec
Take a look →