New in GA4: Create and Modify Events with Regex

April 6, 2023 

Google Analytics 4 (GA4) is introducing an exciting new feature: regex support when creating events. This powerful addition to the GA4 platform means users can now create more sophisticated events that track visitor activity on their website with greater accuracy, giving them access to an even deeper understanding of their audience and how they interact with their site.

Regex, or Regular Expressions, is a sequence of characters that defines a search pattern. It’s used  in many programming languages including JavaScript, Python, and PHP, to match character combinations in strings, and, can be used for various tasks such as validating email addresses and searching for specific patterns within text. With the help of regex tools like RegExr and Regex101, it’s easy to learn how to use regex for your own projects.




Using regex support, GA4 users are able to customize the structure of event parameters so that each event includes a unique identifier instead of relying on a generic category parameter. This makes it easier for analysts to view and analyze specific user actions such as clicking a button or downloading certain types of files. With this increased level of detail, the insights gained from GA4 become even more meaningful.


In addition to providing a better way to track user behavior, regex also helps users reduce event tracking complexity which in turn leads to improved performance of the analytics system. This is especially important for larger websites with hundreds or thousands of pages – where too many events can cause significant delays in loading or displaying data in reports.

Not only does regex enhance reporting capabilities but it allows website owners to filter out traffic that isn’t relevant, thus reducing the amount of noise in their data and making it easier to identify patterns and trends that may otherwise go unnoticed.



Regex Use Cases in Google Analytics 4


Regex is a powerful tool for filtering and matching data in Google Analytics 4, allowing you to get the most out of your analytics platform and make informed decisions about your business strategy. With these 6 real-world use cases for regex in GA4, you’ll be able to take advantage of this powerful feature and make sure your analytics are working for you!

  1. Create and/or modify events – With regex, you can create or modify events in GA4 to help you migrate destinations and track user behavior more accurately.
  2. Filter reports – Regex can be used to filter Google Analytics Exploration reports, allowing you to focus on the data that matters most to your business.
  3. Match strings – You can use regex to match strings of text anywhere in your data, such as matching “she” or “he” in user profiles.
  4. Match multiple words – You can also use regex to match multiple words at once, such as matching “this”, “those”, or “that”.
  5. Ignore case sensitivity – Regex allows you to ignore case sensitivity when matching strings of text, making it easier to find the data you need quickly and efficiently.
  6. Track user behavior – Finally, regex can be used to track user behavior more accurately by filtering out irrelevant data from your reports.
  7. Filter Internal IPs – Under Configure Tag Settings and Define Internal traffic, you don’t need to rely only on Equals, Beings, Contains, Ends, and CIDR notation. Regex can now be used to cover multiple IPs.
  8. Filter Unwanted Referrals – Referrals also received an update and you can use Regex now to cover multiple domains that you don’t want to fall under the referrals report.

Google Analytics 4 is an invaluable tool for website owners who want to maximize the potential of their data. The addition of regex support will provide users with even greater control over event tracking, enabling them to gain a deeper understanding of how visitors interact with their site.

The possibilities are endless when it comes to leveraging Google Analytics 4’s new regex feature – allowing users to unlock valuable insights into visitor behavior while also optimizing their performance and effectiveness in reporting. Regex support is setting the standard for event tracking and website analytics. Through this enhanced level of detail, website owners can make better-informed decisions that lead to improved user experiences and long-term success.


Learning About the Latest GA4 Updates at Napkyn

At Napkyn, we keep track of the latest Google Analytics 4 developments and post updates to ensure you are always in the loop regarding new features and how to use them.  Sign up for our monthly newsletter to get the latest scoop on Google Analytics 4 as well as useful guides for getting the most out of this platform.

Have questions about transitioning or getting the most out of your GA4 implementation? Contact us.


Latest Articles

Ricardo Cristofolini July 3, 2024
Shreya Banker, Data Scientist June 20, 2024
Ricardo Cristofolini June 10, 2024

Have questions about transitioning or getting the most out of your GA4 implementation?