GA4 DataLayer Generator

Generate a valid GA4 dataLayer push for any event, with the parameter names GA4 actually reads.

GA4 DataLayer

Generator

FREE

Hand written dataLayer code is where most GA4 setups break. Fill in the event, copy a clean snippet and paste it straight into GTM.

TOOL.

FREE

NO SIGN UP

SGTM READY

Event*

Pick a GA4 recommended event where one fits. The parameter fields change with the event.

Custom Event Name

Only used when Custom event is selected. Lowercase with underscores.

Platform

Changes the comment and the trigger example in the snippet, nothing else.

Include Ecommerce Clear

Adds a null ecommerce push before the event so item data never leaks between pushes.

Event parameters

Required and recommended parameters for the selected event are rendered here.

Your dataLayer snippet

// Pick an event to generate the snippet.

Custom Event trigger

/

Data Layer Variables to create

/

GA4 event tag name

/

Server side forwarding

/

Paste the snippet into a GTM Custom HTML tag, or into your site code above the GTM container, then fire the GA4 event tag on a Custom Event trigger that matches the event name.

FAQ

Common questions

Why clear the ecommerce object before each push?

+

GTM merges new dataLayer pushes into existing ones. Without the clear, items from an earlier view_item can leak into the next add_to_cart.

Should I use recommended or custom events?

+

Recommended events like purchase and generate_lead fill GA4's built-in reports automatically. Use a custom event only when no recommended event describes the action.

Where does the code go?

+

On the page where the action happens, fired at the moment it happens: on the order confirmation for purchase, and on a successful form submit for generate_lead.

book a meeting

Talk to an Expert

"craze is an absolute 10 out of 10 on ease to work with.”

Matt Van Itallie

CEO, Sema

STRAIGHT FROM ADS MANAGER

Ads that pull their weight.

Tracking and Attribution Build

Find your missing

piece

Server side tracking that closes the data blindspots and maps every marketing dollar to real revenue. Fixed scope, fixed timeline.