GA4 Event Filter Regex — Patterns That Actually Work (and a Free Generator)
Building a GA4 event filter regex for several event names, a prefix convention or an event parameter? This page explains exactly how GA4 evaluates your pattern, then gives you copy-paste ga4 event name regex recipes — each one testable in the free regex tester before you paste it into an exploration, key event or audience rule.
Two rules first: GA4 regex is a full match — page_view matches only page_view, never page_view_v2 — and GA4 runs RE2, so lookahead (?=…) and backreferences \1 fail silently. Full-match is actually good news for event filters: alternation alone is precise enough, no anchors needed.
How GA4 evaluates an event filter regex
Apply regex to the event_name dimension in explorations, custom reports, audiences or key-event conditions. GA4 checks whether your pattern matches the entire event name:
- Alternation is exact by default.
(purchase|begin_checkout)matches only those two names — nothing can "slip in" around them. - Prefix / suffix / contains need explicit
.*:myapp_.*,.*_click,.*checkout.*. - Case-sensitive. GA4 event names are lowercase by convention — keep patterns lowercase.
- RE2. No assertions, no backreferences. Character classes, groups and
.*cover every realistic event-filter need.
Event name regex patterns
Click any row to load the pattern plus a sample event list into the tester.
Multiple events (alternation)
| You want | Regex | |
|---|---|---|
| The core ecommerce funnel | (view_item|add_to_cart|begin_checkout|add_payment_info|purchase) | Try in tester → |
| Scroll + video engagement | (scroll|video_start|video_progress|video_complete) | Try in tester → |
| File downloads & shares | (download|file_download|share) | Try in tester → |
| Search events | (search|search_results|view_search_results) | Try in tester → |
Conventions: prefixes, suffixes, contains
| You want | Regex | |
|---|---|---|
All custom events under myapp_ | myapp_.* | Try in tester → |
Any event ending in _click | .*_click | Try in tester → |
Any event ending in _view | .*_view | Try in tester → |
| Events containing "checkout" | .*checkout.* | Try in tester → |
All begin_* events | begin_.* | Try in tester → |
| Exactly one event name | page_view | Try in tester → |
Note the last row: page_view matches only page_view — page_view_v2 stays out. That is full-match working in your favor.
The "generator" recipes (build any event filter in 10 seconds)
Every event filter regex is one of four shapes. Pick the shape, swap in your text:
- List of exact names →
(name1|name2|name3)— paste your list between the pipes. - Prefix convention →
prefix_.*— e.g. allcrm_events:crm_.*. - Suffix convention →
.*_suffix— e.g. every_click. - Contains a word →
.*word.*— e.g. anything with "checkout".
Then validate the result against your real event list in the tester before touching GA4 — one wrong pipe or forgotten .* is exactly what produces empty reports.
Regex on event parameter values
Regex also works on dimensions that carry parameter values (built-in ones like page_location, or custom dimensions you register):
| You want | Regex | |
|---|---|---|
| Currency is USD or EUR | (USD|EUR) | Try in tester → |
| Item name contains "Pro" | .*Pro.* | Try in tester → |
| Any URL with a query string | .*\?.* | Try in tester → |
| Traffic tagged with utm_medium | .*[?&]utm_medium=.* | Try in tester → |
Remember: page_location holds the full URL; parameter dimensions hold the value only (e.g. email, not utm_medium=email — drop the parameter name when filtering the dimension itself).
Why event filters return no data
- Expected a partial match.
page_viewdoes not coverpage_view_v2— add.*or include both names. - Anchors used as a crutch.
^(purchase|begin_checkout)$works, but the anchors are redundant — GA4 already matches the full string. - Lookahead for exclusions.
^(?!page_view).*fails in RE2. Use GA4's exclude / "does not match" filter instead. - Filtered a parameter name, not its value. The dimension carries the value; the pattern must match the value alone.
- Uppercase slipped in.
Purchase≠purchase.
FAQ
How do I filter multiple events in GA4 with regex?
Alternation: (purchase|begin_checkout|add_to_cart). Because GA4 matches the full string, each name matches exactly — no anchors required and nothing extra can slip in.
Why does my event regex not match in GA4?
Check three things: full-match (does your pattern cover the whole name?), case (GA4 is case-sensitive), and engine (RE2 rejects lookahead/backreferences silently).
Can regex filter event parameter values?
Yes — apply it to the dimension carrying the value (a custom dimension or built-in one like page_location), not to event_name.
Does GA4 event regex support lookahead?
No. GA4 uses RE2. For "match X but not Y", add a second exclude filter in GA4 rather than an assertion.
More shapes and examples in the GA4 regex cheat sheet, and page-specific patterns in the GA4 page path regex guide.