Google Analytics 4 now lets you modify and create events using regular expressions

This allows you to migrate destination and event goals using regex.

Chat with SearchBot

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:

Google Analytics Regex


About the author

Barry Schwartz
Staff
Barry Schwartz is a technologist and a Contributing Editor to Search Engine Land and a member of the programming team for SMX events. He owns RustyBrick, a NY based web consulting firm. He also runs Search Engine Roundtable, a popular search blog on very advanced SEM topics.

In 2019, Barry was awarded the Outstanding Community Services Award from Search Engine Land, in 2018 he was awarded the US Search Awards the "US Search Personality Of The Year," you can learn more over here and in 2023 he was listed as a top 50 most influential PPCer by Marketing O'Clock.

Barry can be followed on X here and you can learn more about Barry Schwartz over here or on his personal site.

Get the newsletter search marketers rely on.