GA4 Event Name Rules — Validation Regex, Limits & Reserved Names
Hitting NAME_INVALID, or cleaning up an event list that has grown twelve spellings of the same action? This page states the GA4 event naming rules exactly as Google documents them, gives you the ga4 event name regex that checks a name against them — with live match/no-match examples — and shows three ways to audit every event name already in your property.
The rules in one line: start with a letter · letters, numbers and underscores only · 40 characters or fewer · no spaces · case sensitive · never a reserved name. Everything below is verified against Google's Event naming rules and Measurement Protocol limits.
The GA4 event naming rules
Google enforces six things when an event name arrives. The first four are format rules, the last two are bookkeeping rules:
| Rule | What Google enforces | Verified against |
|---|---|---|
| Start character | Must start with a letter (an alphabetic character). 2fa_login and _signup are both rejected. | MP limits + NAME_INVALID response |
| Allowed characters | Only letters, numbers and underscores. No spaces, hyphens, dots, slashes, emoji or punctuation. | MP limits · naming-rules help page |
| Length | 40 characters or fewer, counted after the name is final. | MP limits |
| Case | Case sensitive: my_event and My_Event are two different events in your reports. | Naming-rules help page |
| Language | English and non-English letters are both allowed (e.g. añadir_al_carrito is a legal name). | Naming-rules help page |
| Reserved names | A published list of names and one prefix you may not use — Analytics shows an error if you try. | Naming-rules help page |
Case sensitivity
GA4 compares event names as case-sensitive strings. my_event and My_Event both satisfy every format rule above, and GA4 will happily collect both — but they are two different events, reported as two different rows, with no warning anywhere in the UI.
- It cuts both ways. The same applies to your filters: an exploration filter of
purchasewill not returnPurchase, and a prefix filter ofcrm_.*missesCRM_signup. - It is the most common cause of "half my events are missing". One tag fires
Form_Submitfrom an old GTM container while another firesform_submitfrom the new one, and the totals never add up. - It cannot be fixed after the fact. Names are immutable once collected, so the fix is at the source — normalise the tag or trigger to lowercase and let the old spelling age out of your reports.
- The convention is lowercase, not "whatever the developer typed". With everything lowercase, one alternation is enough:
(purchase|begin_checkout|add_to_cart)instead of shipping every combination of cases.
| You want | Regex | |
|---|---|---|
| Find event names containing an uppercase letter | [A-Z] | Try in tester → |
| Match every case spelling while you migrate | ^(purchase|Purchase|PURCHASE)$ | Try in tester → |
| Find case drift between two spellings | ^(purchase|Purchase)$ | Try in tester → |
Do not paste (?i) into this tester or into GA4. JavaScript's RegExp has no inline-flag syntax — new RegExp('(?i)purchase') throws Invalid group — and GA4 offers no case-insensitive option at all. (?i) belongs to BigQuery, Python and other PCRE-flavoured engines, where it is a legitimate audit crutch; GA4-side, list the spellings in the alternation instead. Where (?i) is legal, where it is not, and its position rules are covered in RE2 vs PCRE.
Reserved event names (web streams)
These are the reserved names Google lists for web data streams. You cannot create or modify an event with one of these names — but automatically collected events already use them, so they still appear in your reports and in your event filter regex patterns:
ad_impression · app_remove · app_store_refund · app_store_subscription_cancel · app_store_subscription_renew · click · error · file_download · first_open · first_visit · form_start · form_submit · in_app_purchase · page_view · scroll · session_start · user_engagement · view_complete · video_progress · video_start · view_search_results
Reserved prefix for web events: query_id. The _, firebase_, ga_, google_ and gtag. prefixes are reserved for parameter and user-property names, not event names — a common point of confusion when people audit a list. App streams have their own, longer reserved list (ad_activeview, ad_click, os_update, …).
The validation regex
Two patterns cover the two real cases. Click any row to load the pattern plus a sample event list into the tester.
| You want | Regex | |
|---|---|---|
| Validate an ASCII event name (the common case) | ^[A-Za-z][A-Za-z0-9_]{0,39}$ | Try in tester → |
Allow non-English letters (añadir_al_carrito) | ^[\p{L}][\p{L}\p{N}_]{0,39}$ | Try in tester → |
| Find a name that is too long (> 40) | ^.{41,}$ | Try in tester → |
| Find a name with a disallowed character | [^A-Za-z0-9_] | Try in tester → |
| Find a reserved web event name | ^(page_view|scroll|session_start|user_engagement|first_visit|form_submit|file_download|view_search_results)$ | Try in tester → |
Why {0,39}? The first character is counted by [A-Za-z], so the class that follows may repeat 0 to 39 more times — the total is exactly 40, never 41. A pattern written as [A-Za-z0-9_]{1,40} would accept 40 characters but also accept a leading digit, which GA4 rejects.
Both patterns are RE2-safe: anchors, character classes and a bounded quantifier only — no lookahead, no lookbehind, no backreferences. That matters because the same expression has to run in three places: the tester (browser JavaScript RegExp), BigQuery REGEXP_CONTAINS, and any GA4/RE2 surface. The Unicode variant needs the u flag in JavaScript; BigQuery's RE2 accepts \p{L} natively. Full details of what RE2 will and will not take are in RE2 vs PCRE.
Where GA4 enforces the rules
- Collection time (gtag / GTM / CAPI). The tag sends the name you typed; GA4 does not rename or sanitize it. A name that breaks the format rules is rejected rather than fixed.
- Measurement Protocol validation server. POST to
/debug/mp/collectand readvalidationMessages: an invalid name returnsvalidationCode: "NAME_INVALID"with a message such as "Event at index: [0] has invalid name [_badEventName]. Names must start with an alphabetic character." - The Admin UI. Creating or modifying an event with a reserved name or prefix shows an inline error.
- Key events (conversions). A name over the limit cannot be marked as a key event, which is how most teams finally notice the 40-character ceiling.
Audit every event name in your property
The rules are easy to follow for a new event and almost never true for a property that is two years old. Three ways to find the violations, fastest first:
- In the tester (30 seconds). Export the event list — Admin → Data collection and modification → Data streams → your stream → Configure your events, or any report with
event_nameas a dimension — paste it one per line, run^[A-Za-z][A-Za-z0-9_]{0,39}$, and read the lines that do not highlight. The event filter guide shows the same workflow for filtering. - In an exploration. Drop
Event nameinto Rows, add a filter on it with matches regex, and enter an inverted alternation of the valid names you expect — GA4's full-match semantics mean anything unexpected simply fails the filter. See GA4 regex match types for which screens match the whole value. - In BigQuery. One query returns every violation, including case drift:
| You want | BigQuery | |
|---|---|---|
| Event names that break the format | WHERE NOT REGEXP_CONTAINS(event_name, r'^[A-Za-z][A-Za-z0-9_]{0,39}$') | Try in tester → |
| Names longer than 40 characters | WHERE LENGTH(event_name) > 40 | Try in tester → |
| Case drift (two spellings of one event) | GROUP BY LOWER(event_name) HAVING COUNT(DISTINCT event_name) > 1 | Try in tester → |
| Names that are not in your approved list | WHERE event_name NOT IN ('page_view','scroll', ...) | Try in tester → |
The BigQuery rows are query fragments, not full statements — pair them with your own FROM. REGEXP_CONTAINS is RE2, so the validation regex runs there unchanged; NOT REGEXP_CONTAINS is the clean way to invert it, since RE2 has no lookahead to build ^(?!...) with.
Naming conventions that keep your regex filters working
The format rules only guarantee that a name is legal. They say nothing about whether your filters will still work in six months — that is a naming decision, and it is where most GA4 event lists rot:
object_action, consistently.video_startandstart_videoare both legal and both wrong. Pick one order and never deviate; a suffix filter like.*_startonly works if the order is fixed.- One separator: underscore. Hyphens and spaces are illegal anyway, but
ctaClickvscta_clickis a legal split that breaks every.*_clickfilter you write later. - Lowercase, always. Not required by Google, but a single uppercase letter doubles your alternation lists:
(purchase|Purchase)instead ofpurchase. - Reserve prefixes for meaning.
crm_,app_,billing_— then onecrm_.*pattern covers every event a team adds under that domain. This is the cheapest insurance against the audit above. - Leave room for the 40 characters.
checkout_completed_with_promo_code_appliedis 44 characters and already illegal. Count before you ship.
None of this is enforced by GA4 — which is exactly why the audit exists. For the filter side of the same problem (which match type each GA4 screen uses, and how full-match changes your patterns), start with GA4 regex match types.
Gotchas
- 40 characters counts the name, not the parameter. Parameter names have their own 40-character rule; parameter values are 100 characters (500 on GA360). Do not reuse one limit for all three.
- Case sensitivity is silent.
my_eventandMy_Eventare both legal, both accepted, and reported as two separate rows — no warning anywhere. - Non-ASCII letters pass, ASCII-only filters do not.
añadir_al_carritois a valid GA4 event name but fails^[A-Za-z][A-Za-z0-9_]{0,39}$. Use the\p{L}variant if your property sends non-English names. - Reserved names are still in your data. You cannot create
page_view, but it is the most common event you will ever filter. Reserved ≠ absent. - Renaming is not an option. There is no alias or mapping: the tag must be changed, and history stays under the old name. Fix it in GTM or the Google tag, then re-validate with the Measurement Protocol debug endpoint.
- Lookahead is not the tool here.
^(?!.*_click$).*fails in RE2. Exclude with a second "does not match" filter instead — see the GA4 regex cheat sheet for the pattern shapes that do work.
FAQ
What are the GA4 event naming rules?
Start with a letter · letters, numbers and underscores only · 40 characters or fewer · no spaces · case sensitive · never a reserved name (web list includes page_view, scroll, session_start, first_visit, form_submit, file_download, …). Source: Google's Event naming rules help page.
What regex validates a GA4 event name?
^[A-Za-z][A-Za-z0-9_]{0,39}$ for ASCII names — a leading letter, then 0–39 letters, digits or underscores, capping the name at exactly 40 characters. Add the u flag and use ^[\p{L}][\p{L}\p{N}_]{0,39}$ if non-English letters must pass.
Where does GA4 reject an invalid event name?
Three places: the Measurement Protocol validation server (/debug/mp/collect) returns validationCode: "NAME_INVALID"; the Admin UI shows an inline error for reserved names and prefixes; and an over-limit name cannot be marked as a key event.
Can I rename an event that already violates the rules?
No. Event names are immutable once collected — fix the tag or GTM trigger that sends the name, then re-check with the debug endpoint. Reports keep the old name for the history already stored.
Filtering reports by event name is covered separately in the GA4 event filter regex guide; ready-made patterns for the same job live in the GA4 regex cheat sheet; which GA4 screen matches the full value versus a substring is in GA4 regex match types. For validation outside GA4 — dates, emails, URLs, IPs, log lines — browse the regex pattern library.