How to use the dataLayer Push Generator
- Choose an event or type your own event name.
- Add parameters and, for ecommerce, items.
- Copy the
dataLayer.push()code into your page. - 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.