Content revised 21 October 2026.
A regular expression matches a text pattern. It can make a report condition more flexible, but a small mistake can include or exclude the wrong records.
Write examples first
List values that should match and values that should not. Decide whether you need a full value or part of a string. Check the exact Analytics feature’s matching behaviour rather than assuming every field treats regex identically.
Use simple patterns
A caret can anchor the beginning, a dollar sign the end and a vertical bar alternatives. Escape special characters when they should be literal. For example, a dot in a hostname pattern should not accidentally stand for any character.
Check the boundaries
Test uppercase, trailing slashes, parameters and unexpected variations. A pattern that matches your three examples can still catch a fourth value you intended to exclude. Keep the condition readable enough for another reviewer.
Document the purpose
Record the field, pattern, examples and owner. Use a report-level test before a higher-impact processing change where appropriate. Regex is a matching tool, not proof that the selected data answers the business question.
Official guidance: Google Analytics regex guidance.

