Google Analytics 4 now lets you modify and create events using regular expressions
This allows you to migrate destination and event goals using regex.
Google Analytics 4 now supports creating and/or modifying events using regular expressions, regex. This can help you migrate destinations and event goals from Universal Analytics to Google Analytics 4 in a more programmatic fashion.
More details. Google said the new feature and options enable you to define conversions using regular expressions (regex) for web data streams. Just be careful with regex, it can get technical and it is very picky.
Why we care. As we approach the deadline for the GA4 migration from UA3, which is now 87 days away, some are now rushing to migrate not just to GA4 but also to migrate all their goals and events. This may help some of you with that migration since regex can be a super powerful way to match old events and migrate them in a more programmatic manner.
How it works. Google explained that to avoid using malformed regex that may impact your site performance, follow these best practices:
- Before you use regex, use other operators where possible (e.g., exact matches, contains).
- Test your regex against expected inputs and ensure that it’s matching what you expect.
- If case sensitivity is important, specify your regex to be case sensitive. Use the option that doesn’t say “(ignore case)”.
Google notes you should avoid unbounded or nested repetitions where matching time can increase exponentially. Also make sure to define a maximum number of expected repetitions.
What it looks like. Here is a screenshot of this interface for using regular expressions:
New on Search Engine Land