GTM dataLayer Push Generator

Build Google Tag Manager dataLayer.push() code for any custom event. Supports string, number, boolean, and nested object/array values. Includes the GA4 ecommerce reset pattern.
Measurement Intelligence
Clean dataLayer events are the single biggest investment you can make in your tag stack.
A consistent dataLayer schema is what lets you swap analytics platforms without re-tagging. This builder enforces type correctness, validates key naming, and includes the ecommerce reset pattern (push ecommerce: null before new ecommerce events) that prevents GA4 data duplication.
Build the push
Variables
The event name + any key/value pairs
Event name *
Recommended for every GA4 ecommerce event. Prevents stale items being reported with new events.
Variables
Generated code

        
GTM trigger setup
  1. Copy the generated code above and fire it from your JavaScript when the event happens.
  2. In GTM, go to Triggers and New and Custom Event.
  3. Set Event name to form_submit (exact match to what you push).
  4. For each variable you want to use in tags, go to Variables and User-Defined and New and Data Layer Variable and set the name to match (e.g. form_name).
  5. Reference the variables in tags using {{form_name}} syntax.
Next steps
Make sure your events respect consent
Set up Consent Mode v2 so your tags fire the right way for EEA + UK traffic.
Frequently asked questions
What is the GTM dataLayer?
A JavaScript array where the site pushes event data. GTM reads from it and routes to tags (GA4, Meta Pixel, etc.).
How is dataLayer different from gtag?
gtag is Google-specific: dataLayer is tool-agnostic: any tag manager can read from it. More portable architecture.
What should go in a dataLayer push?
Event name + relevant parameters. For ecommerce: event: "purchase", ecommerce: { items: [...] }.
Should I push on every page?
A base push with page type, user ID (if logged in), and other persistent attributes on every page. Event-specific pushes on top.
What are naming conventions?
snake_case for keys, lowercase values. Follow GA4 recommended event names (purchase, add_to_cart) for native GTM integration.
Can I nest objects?
Yes. GTM reads nested paths like ecommerce.items[0].price. GA4 ecommerce schema uses nesting.
When does the push need to happen?
Before the GTM tag loads for initial-load data. On user interaction for event-driven data (click, scroll, purchase).
What is a Custom Event in GTM?
A GTM trigger that fires on a specific event value in the dataLayer. The link between site push and tag execution.
Should the site push to dataLayer or use GTM Click triggers?
For reliable data, push from the site. GTM auto-triggers are convenient but miss dynamic content and don't survive SPA navigation.
How does dataLayer work with SPAs?
Push virtual pageviews on route change. GTM History Change trigger alternatively. Many SPAs use both.
Can I debug dataLayer in the browser?
window.dataLayer in the browser console shows all pushes. Also GTM Preview mode has a dedicated dataLayer tab.
Free · no account

SEORCE for Chrome, Edge and Firefox

Audits the page you are on: headings, meta tags, schema, indexability, and whether AI crawlers can read it. Export the result as a PDF. Free, with no account.

It audits one page at a time and does not track AI answers. About the extension

Traffic from search and AI

See which visits came from search and AI.

SEORCE Web Analytics runs from one script tag, with Google Search Console connected. It shows visits from every AI source, from search and from campaigns, and it is free on every plan.
3,000+ users · Free forever plan, no card needed