For web data streams, you can modify and generate a new event in Google Analytics using a regular expression (regex).
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 Analytics 4 executes Event Creation and Modification rules directly on the browser. As a result, certain types of invalid regex run the risk of decreased website performance.
Best practices to avoid catastrophic backtracking
- Avoid unbounded or nested repetitions where matching time can increase exponentially. Define a maximum number of expected repetitions.