Sub topic 6
Custom events: when nothing predefined fits
This chapter assumes you have a GA4 property with a web data stream. It also assumes you can read JavaScript objects and function calls. You should know what an event and an event parameter are, and which events GA4 collects on its own and which it recommends. Here you learn when to send a custom event, how to build one, and what goes wrong when you do.
What a custom event is
A custom event is an event whose name you choose. GA4 does not define it for you. It is not collected automatically, not part of enhanced measurement, and not on the recommended events list. GA4 stores it like any other event: a name, a timestamp, a set of parameters, and the user and session context that GA4 adds.
Because GA4 has no predefined meaning for the name, the event appears in reports only by name. Its parameters are visible in DebugView and the raw export. They are not available in standard reports or explorations until you register them as custom dimensions or metrics.
When to use one
Use a custom event only after you have checked the other options. The order is:
- Check whether GA4 already collects the interaction (automatic or enhanced measurement events).
- Check whether a recommended event describes it.
- If neither fits, send a custom event.
Recommended events are better when they fit. Their names and parameters have built-in meaning in GA4. For example, purchase feeds the monetization reports. A custom event named order_done gets none of that.
Good reasons to go custom:
- The interaction is specific to your product, such as a newsletter button click, a calculator being used, or a feature toggle.
- No recommended event matches the meaning, even loosely.
- You need a distinct event name so that you can mark it as a key event or build an audience on it.
Poor reasons to go custom:
- You dislike a recommended event's name. Renaming it loses its built-in handling.
- You want to track a value that is really a parameter. For example, create one
video_playevent with avideo_titleparameter. Do not createvideo_play_intro,video_play_pricing, and so on.
Sending a custom event with gtag.js
This example assumes the standard GA4 gtag.js snippet is already on the page, so gtag is defined.
gtag('event', 'newsletter_signup_click', {
placement: 'footer',
plan_type: 'free'
});The call has three parts:
'event'is the command.'newsletter_signup_click'is the event name.- The object holds the event parameters. Each key is a parameter name, and each value is a string or a number.
Here placement and plan_type are the custom parameters. They let one event answer several questions: where on the page the click happened and which plan it was for. The alternative is to multiply event names.
The same event through Google Tag Manager
With Google Tag Manager (GTM), your page code pushes to the data layer instead of calling gtag. A GA4 event tag then reads the values.
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'tutorial_complete',
tutorial_id: 'ga4-events-101'
});In GTM you would set up three things:
- A Custom Event trigger whose event name is
tutorial_complete. - A Data Layer Variable named
tutorial_id. - A GA4 event tag with the event name
tutorial_completeand an event parametertutorial_idthat uses the variable. The tag fires on that trigger.
The event key in the data layer is the name GTM matches against. The GA4 event name is a separate field in the tag. They can differ, but keeping them the same makes debugging easier.
Naming rules and limits
GA4 enforces rules on names. Events that break them can be dropped or can fail to appear without a visible error.
| Item | Rule |
|---|---|
| Event name length | Up to 40 characters |
| Parameter name length | Up to 40 characters |
| Parameter value length | Up to 100 characters on standard properties |
| Characters allowed | Letters, numbers, and underscores |
| First character | Must be a letter |
| Case | Names are case-sensitive, so `Sign_Up` and `sign_up` are different events |
| Reserved prefixes | `google_`, `ga_`, and `firebase_` |
| Parameters per event | Up to 25 |
Some names are reserved for GA4's own use. Examples are first_visit, session_start, and user_engagement. Do not reuse them for your own events. Limits change over time, so check Google's current documentation when you plan a large implementation.
Follow these habits:
- Use
snake_case, which is lowercase words joined by underscores. Google's own events use it. - Name events with a verb or an object plus an action, such as
calculator_useorbrochure_download. - Put variable detail in parameters, not in the event name.
- Never put personally identifiable information, such as email addresses, in event names or parameters. This violates Google's terms of service.
There is also a cap on the number of distinct event names a property accepts. It is generous, around 500 distinct names. You reach it only when names are generated dynamically, for example when a page URL or product title ends up inside the name. That is one more reason to keep names fixed and move variable data into parameters.
Parameters need registering before reports can use them
Sending a parameter does not make it appear in standard reports. For a custom parameter, do this:
- In Admin, open Custom definitions.
- Create a custom dimension with scope Event. Set the event parameter field to the exact parameter name, such as
placement. Use a custom metric instead if the value is numeric and you want to sum or average it. - Wait. Data can take up to about 24 hours to appear.
Two consequences follow:
- Registration is not retroactive. Data sent before you registered the parameter is not backfilled into the dimension.
- A typo in the parameter name creates a dimension that never fills. The name in the registration must match the name in the code exactly, including case.
A standard property allows a limited number of custom dimensions: 50 event-scoped, 25 user-scoped. Register only the parameters you will report on.
Common errors
- The event never shows up. Check that the name follows the rules, that the
gtagsnippet loaded before your call, and that no consent setting blocks collection. Open DebugView to see whether the hit arrives. - Two near-identical events.
Newsletter_Signupandnewsletter_signupare separate. Choose one convention and write it into a tracking plan. - A parameter is missing from reports. You sent it but did not register it as a custom dimension, or you registered it recently and the data has not arrived yet.
- A custom event duplicates a recommended one. For example,
add_to_cart_clicknext toadd_to_cart. This splits data and breaks ecommerce reports. Use the recommended event. - Values with inconsistent types. Send
priceas a number, not sometimes'29.99'and sometimes29.99. A custom metric needs a numeric value. - A GTM tag fires on every push. If the Custom Event trigger is set to match a regular expression loosely, other data layer events can fire the tag. Use an exact match on the event name.
A short worked decision
Your site has a "Compare plans" toggle. You want to know how often users switch between monthly and annual billing.
- Automatic and enhanced measurement events: none covers a toggle.
- Recommended events: none describes a billing toggle.
- Decision: custom event.
A reasonable design is one event, billing_toggle, with a parameter billing_period that is monthly or annual. The name has 14 characters and uses only allowed characters. Register billing_period as an event-scoped custom dimension. If the toggle matters to your business goals, you can later mark billing_toggle as a key event.
gtag('event', 'billing_toggle', {
billing_period: 'annual'
});Exercise
A teammate wants to track a "Download price list" button. They propose the event names Download_PriceList_PDF_Spring2026 and download_pricelist_pdf_summer2026, depending on the campaign. List what is wrong with this plan and propose a better design.
Show answer
The names mix upper and lower case, so they are case-sensitive and easy to duplicate by accident. They also put changing campaign detail into the event name, which multiplies distinct event names and splits the data into separate events. A better design is one snakecase event, such as `pricelistdownload, with parameters like filename and campaignseason. Register campaignseason (and filename if needed) as event-scoped custom dimensions so reports can break the event down by them. Before choosing a custom event, check whether the recommended filedownload` event, which enhanced measurement can already collect, covers the interaction.