What is a GTM data layer?
The GTM data layer is a JavaScript array (window.dataLayer) that your website uses to communicate structured data to Google Tag Manager. Your website "pushes" objects into this array — containing event names, product information, user attributes, and other relevant data — and GTM reads these values through "data layer variables" to make them available to your tags and triggers. It creates a clean separation between your website's code and your tracking infrastructure.
Why do I need a data layer? Can't GTM just read values from the page?
GTM can read some values directly from the page using auto-event variables, CSS selectors, and JavaScript variables. However, page-scraping approaches are fragile — they break whenever your design or HTML structure changes. Critical data like product prices, transaction IDs, and user attributes is often not present in the page HTML at all. A data layer provides reliable, structured access to all the data your tracking needs, independent of page design.
What is the difference between a client-side data layer and server-side data?
A client-side data layer is a JavaScript array in the browser that GTM reads to access event data. It is the standard approach for most tracking implementations. For sensitive data or for server-side tracking implementations, you may also need to pass data from your server to your server-side GTM container — either by forwarding client-side events or by triggering server-side events directly from your application backend.
How does the data layer work for ecommerce tracking?
For ecommerce, your website pushes structured data layer events at each shopping journey touchpoint. For example, when a user views a product page, your website pushes a view_item event with an items array containing product name, ID, price, brand, and category. GTM reads this data via data layer variables and passes it to your GA4 ecommerce tag and Google Ads dynamic remarketing tag. Without this push, GA4 has no way to know which product the user viewed.
Can you implement a data layer on a React or Next.js website?
Yes. React and Next.js sites have specific implementation considerations — particularly around the component lifecycle, virtual page view events for client-side navigation, and the timing of data layer pushes relative to component rendering. We specialise in data layer implementations on modern JavaScript frameworks and handle all framework-specific challenges in our implementation.
What data should be included in a purchase event data layer push?
A complete purchase event data layer push should include: event name (purchase), transaction_id (unique order ID), value (order total), currency, shipping, tax, coupon, and an items array with one object per product containing item_id, item_name, item_brand, item_category, item_variant, price, and quantity. Incomplete item arrays — missing price or item_id — are the most common cause of broken ecommerce tracking.
How long does a data layer implementation take?
A data layer implementation timeline depends on your website's complexity and your development team's capacity. The specification and design phase (our work) typically takes 3–7 days. Development implementation of the data layer pushes into your website typically takes 1–3 sprints depending on the number of events and your team's other priorities. We provide detailed specifications to minimise development time and QA cycles.
What is a data layer audit?
A data layer audit reviews your existing data layer implementation to verify that every event pushes the correct data at the correct time, all variable values are accurate and consistently formatted, and no events are missing, duplicated, or firing out of sequence. We use GTM Preview mode and browser console inspection to validate every data layer push against your intended specification.
How do I document a data layer specification?
A data layer specification document lists every event name, the conditions under which it fires, every property in the event object with its data type and expected values, and example payloads. We produce this specification as part of our data layer design service, providing your development team with everything they need to implement correctly without guesswork.
What happens to tracking when my website is redesigned?
With a properly designed data layer, a website redesign should not break tracking — as long as the data layer events remain in place. The data layer is independent of your visual design. However, a redesign typically involves new pages, new user flows, and potentially a new tech stack — all of which may require data layer updates. We offer redesign readiness reviews to identify which data layer pushes need updating before launch.