Advertisement

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:

RuleWhat Google enforcesVerified against
Start characterMust start with a letter (an alphabetic character). 2fa_login and _signup are both rejected.MP limits + NAME_INVALID response
Allowed charactersOnly letters, numbers and underscores. No spaces, hyphens, dots, slashes, emoji or punctuation.MP limits · naming-rules help page
Length40 characters or fewer, counted after the name is final.MP limits
CaseCase sensitive: my_event and My_Event are two different events in your reports.Naming-rules help page
LanguageEnglish and non-English letters are both allowed (e.g. añadir_al_carrito is a legal name).Naming-rules help page
Reserved namesA 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.

You wantRegex
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 wantRegex
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

Check a name before you ship the tag
Paste your candidate names one per line — the validation regex above highlights every one that GA4 would reject.
Open the GA4 regex tester →

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:

  1. 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_name as 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.
  2. In an exploration. Drop Event name into 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.
  3. In BigQuery. One query returns every violation, including case drift:
You wantBigQuery
Event names that break the formatWHERE NOT REGEXP_CONTAINS(event_name, r'^[A-Za-z][A-Za-z0-9_]{0,39}$')Try in tester →
Names longer than 40 charactersWHERE LENGTH(event_name) > 40Try in tester →
Case drift (two spellings of one event)GROUP BY LOWER(event_name) HAVING COUNT(DISTINCT event_name) > 1Try in tester →
Names that are not in your approved listWHERE 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:

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

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.