Home › Tools › Analytics and Tracking Tools › GA4 Event Code Generator
Free Analytics Tool

GA4 Event Code Generator

Choose a recommended event or name your own, add parameters, and get ready to paste gtag.js or Google Tag Manager data layer code. Every name and value is checked against GA4 rules as you type.

Your Event

Event Code


      
Copied!
0Parameters
0Name Length
0Items
Before you publish
  • gtag code needs the Google tag already on the page
  • dataLayer code needs a GA4 Event tag in GTM with a matching Custom Event trigger
  • Check the event in GA4 DebugView before you rely on it

What Is a GA4 Event Code Generator?

Everything Google Analytics 4 records is an event. Page views and scrolls are collected for you, but leads, sign ups, purchases and button clicks usually need a few lines of code. This generator writes that code for you, either as a gtag() call for sites using the Google tag, or as a dataLayer.push() for sites using Google Tag Manager.

Small mistakes break events quietly. A space in a name, a value sent as text with a currency symbol, or a missing currency can mean GA4 drops the data or shows zero revenue. The checker flags these problems as you type, using Google's event naming rules and event collection limits.

How to Use the Generator

  1. Pick a recommended event such as generate_lead or purchase, or choose Custom event and type your own name.
  2. Edit the parameters, one per line, as name = value. Numbers are sent as numbers, and IDs stay as text.
  3. Add items for ecommerce events, one product per line, as id | name | price | quantity.
  4. Choose gtag.js or dataLayer and when the event should fire: right away, on a click, or on a form submit.
  5. Copy the code into your page, then confirm the event arrives in GA4 DebugView.

GA4 Event Rules and Limits

RuleLimit
Event name length40 characters
Parameter name length40 characters
Parameter value length100 characters (page_title 300, page_referrer 420, page_location 1,000)
Parameters per event25
Allowed charactersLetters, numbers and underscores, starting with a letter
Reserved prefixes_, firebase_, ga_, google_, gtag.
Value and currencyIf you send value, also send a three letter currency
ItemsEach item needs item_id or item_name

Tips for Reliable Event Tracking

Go Further With GA4 Events

Follow our step by step guide to GA4 custom event tracking in Google Tag Manager, copy full examples from GA4 ecommerce events examples, and learn the difference between events and conversions. Testing a filter on your new event names? Try the GA4 regex tester.

Frequently Asked Questions

1Should I use gtag.js or dataLayer code?

Use gtag.js code if your site loads the Google tag directly. Use dataLayer.push code if you manage tags in Google Tag Manager, then create a GA4 Event tag with a Custom Event trigger that matches the event name.

2Why is my event not showing in GA4 reports?

Standard reports can take up to a day to update. Check DebugView or the Realtime report first. If the event is missing there, look for a name with spaces or capitals, a reserved name, or code that runs before the Google tag loads.

3Do I need to send currency with value?

Yes. Google's reference says currency is required whenever you set value. Without it, revenue and value metrics are not calculated correctly.

4Is my event data uploaded?

No. The code is generated in your browser and nothing you type is sent to a server.

Related Articles

More Free Analytics and Tracking Tools

See all analytics and tracking tools →  |  Browse every free tool →