spyc.ai

Free tool

GA4 Event Generator

Pick a GA4 recommended or custom event, add parameters, and copy the gtag snippet and dataLayer push.

How it works

What is the GA4 Event Generator?

The GA4 Event Generator is a free tool that writes the code for a Google Analytics 4 event. Pick a recommended event such as purchase or sign_up, or type a custom name, fill in the parameters, and copy the gtag('event', ...) snippet or the equivalent dataLayer.push. It checks the name against GA4's naming rules as you type.

How to use the GA4 Event Generator

  1. Pick a recommended event from the list, or choose Custom event and type a name.
  2. Fill in the parameters, one key=value per line. Empty values are left out.
  3. For ecommerce events, add one item per line: ID, name, price, quantity.
  4. Read any warnings about the name or parameters, then copy the gtag snippet or the dataLayer push.

What is a GA4 event?

In Google Analytics 4 everything is an event: a page view, a scroll, a purchase, a form submission. An event has a name and a set of parameters that describe it, such as value and currency on a purchase or method on a sign-up.

Some events are collected automatically once the Google tag is on the page. Others you send yourself, either with a gtag('event', ...) call in the page or with a dataLayer.push that a Google Tag Manager tag picks up. This tool writes both forms from the same input.

What are GA4 recommended events?

Recommended events are names and parameters that Google documents for common actions: purchase, add_to_cart, begin_checkout, view_item, generate_lead, sign_up, login, search, select_content and others. Using the documented name and parameters is what fills GA4's built-in reports, such as the ecommerce reports, and keeps your data compatible with features Google adds later.

The generator pre-fills the documented parameters for nine of them. If none fits the action, send a custom event with your own name. Custom parameters only show up in reports after you register them as custom dimensions or metrics in GA4 Admin.

What are the GA4 event naming rules?

An event name can be up to 40 characters, must start with a letter, and may contain only letters, digits and underscores. Spaces and hyphens are not allowed. Names are case sensitive, so Sign_Up and sign_up are two different events. The prefixes firebase_, ga_, google_ and gtag. are reserved.

The tool flags each of these. It also warns when you pick a name Google lists as reserved for web, such as page_view or session_start, because those are collected automatically and a manual copy counts twice unless you have switched the automatic one off. Parameter names follow the same 40-character rule, and standard properties keep the first 100 characters of a parameter value.

Should I use gtag or dataLayer.push?

Use the gtag snippet when the Google tag is installed directly in your site's code. The call sends the event to GA4 as soon as it runs.

Use the dataLayer.push when the site runs Google Tag Manager. The push sends nothing by itself. It puts the event and its values into the data layer, and a GA4 event tag with a Custom Event trigger forwards it. The GTM dataLayer Generator lists the trigger and variables to create for that.

How do I check that a GA4 event is firing?

Open GA4's DebugView (Admin, then DebugView) with debug mode on, or use Tag Assistant, and trigger the action on your site. The event should appear within seconds with its parameters. Realtime shows it shortly after.

Standard reports can take a day or more to include new events. If the event should come from a server instead of the browser, build the request with the GA4 Measurement Protocol Builder.

Questions

How many parameters can a GA4 event have?
Up to 25 parameters per event. The tool warns when you go over, because GA4 drops the extras.
Why does my value not show as revenue?
GA4 needs currency alongside value to compute revenue. The tool warns when value is set without currency.
Does the tool send the event to Google Analytics?
No. It only writes the code. You paste it into your site or tag manager, and it runs there.
How do I keep a number as text, such as an order ID?
Keys ending in _id or _name are always sent as text. For any other key, wrap the value in quotes, for example zip="01234".
Is the GA4 Event Generator free?
Yes, with a free spyc.ai account. It runs entirely in your browser, so nothing you type or paste is sent to a server.

Analytics Tools

More in Analytics Tools

GA4 Measurement Protocol Builder

Build a GA4 Measurement Protocol request: JSON body, collect and debug URLs, and a curl command.

Build request

GTM dataLayer Generator

Write dataLayer.push code for GA4 ecommerce and custom events, with the GTM variables to create.

Generate dataLayer

Consent Mode v2 Generator

Set Consent Mode v2 default states, regions and wait time, and copy the gtag default and update snippets.

Generate snippet

Ready when you are

Before your next buyer asks AI about you, ask AI about yourself

One check, four engines, about twenty seconds. We show you the answers before we ask for anything.