dataLayer Push Generator — Google Tag Manager Events

Build dataLayer.push() code for Google Tag Manager: choose a GA4 recommended event or your own, add parameters and ecommerce items, and optionally wrap it in a click or form submit listener — ready to paste.

Runs in your browserUpdated

Items

Your data never leaves your computer. All processing happens 100% locally in your browser.

How to use the dataLayer Push Generator

  1. Choose an event or type your own event name.
  2. Add parameters and, for ecommerce, items.
  3. Copy the dataLayer.push() code into your page.
  4. In Tag Manager, add a Custom Event trigger with the same name and a GA4 event tag that reads the values through Data Layer Variables.

Wiring it up in Tag Manager

Each push needs an event key — that is what a Custom Event trigger listens for. Read the other keys with Data Layer Variables (for example form_name) and pass them as event parameters in the GA4 tag. For ecommerce, check “Send ecommerce data” in the GA4 tag and it reads ecommerce.items for you. Install the container with the GTM Snippet Generator.

Also searched as: datalayer push code, gtm datalayer event, gtm custom event, datalayer ecommerce, datalayer push example, gtm event code.

Tools that pair well with the dataLayer Push Generator

  • GA4 Event Code Generator — Pick a recommended GA4 event — generate_lead, sign_up, purchase, add_to_cart and more — or name your own, fill in the parameters and items, and copy the code as gtag(), a Tag Manager dataLayer.push() or a server-side Measurement Protocol request.
  • Event Tracking Script Generator — Track button clicks, links and form submits by adding attributes instead of code: data-track="sign_up_click" plus optional data-track-* parameters.
  • GA4 Request Decoder — Debug Google Analytics 4 without guesswork.
  • UTM Builder — Add utm_source, utm_medium, utm_campaign and friends to any link, see which GA4 channel the visit will land in, and tag a whole list of URLs at once.

Frequently asked questions

Why push ecommerce: null first?
The dataLayer merges objects, so items from an earlier push can carry into the next event. Clearing ecommerce first is what Google recommends.
Does the dataLayer need to exist before GTM loads?
The generated code starts with window.dataLayer = window.dataLayer || [], so it works before or after the container loads.
How do I read a value from the push in a tag?
Create a Data Layer Variable in Tag Manager with the key name, such as form_name, and use it in the tag as {{DLV - form_name}}.
Can I install dataLayer Push Generator as a web app and use it offline?
Yes. dataLayer Push Generator is an installable web app (PWA) — installed from your browser, not downloaded from an app store. Click Install app at the top of this page in Chrome or Edge (Windows, macOS, Linux, ChromeOS) or on Android, use Share → Add to Home Screen on iPhone and iPad, or File → Add to Dock in Safari 17+ on a Mac. It then opens in its own window with its own icon, and because it runs entirely in your browser it keeps working offline. Firefox on desktop can’t install web apps. How installing works.

Related tools