Free – no sign-up

GTM Regex Generator

Generate ready-to-use regular expressions for typical GTM triggers – and test them directly against your own sample URLs.

  1. Step 1

    Choose a use case

    From “URL contains” to “detect file extension”.

  2. Step 2

    Enter values

    One or more URLs/paths – special characters are escaped.

  3. Step 3

    Test & copy the regex

    Check with your own test URLs and apply it.

Regular expression

Regular expression
^(/kontakt/|/beratung/|/angebot/)$

Matches one of 3 given values.

Regex tester

One test URL per line. The tool shows for each line whether the expression matches.

  • Match/kontakt/
  • No match/impressum/
  • Match/beratung/

GTM note: triggers like “Page URL” and RegEx table variables can have different match settings. Check whether you want a partial match (no anchor) or a full match (with ^…$).

What does the GTM Regex Generator do?

It builds regular expressions for typical GTM use cases: a URL contains a term, starts with a path, ends with a string, combines multiple paths or detects file extensions. Special characters are escaped correctly and anchors are only added when needed.

When should you use it?

When a GTM trigger should react to multiple URLs or a pattern instead of a single exact URL. Typical: one trigger for all thank-you pages, for several landing pages or for PDF downloads.

Which mistakes does it prevent?

Unescaped special characters (a dot in a URL is a wildcard in regex), misplaced or forgotten anchors and accidentally over-broad patterns. The built-in tester instantly shows which of your sample URLs match.

Technical limitations

The generator covers the most common cases. Always test very complex patterns against real sample URLs with the tester. Also note that different GTM variables (URL vs. Page Path) provide different inputs.

Official Google documentation: developers.google.com/tag-platform/tag-manager

Next step

Regex created – now automate the trigger and GA4 tag

Got the right expression? With the GTM Builder you create the matching trigger and GA4 tag too – in a separate workspace you review before publishing.

FAQ

Do I have to escape special characters in GTM?

Yes. In regular expressions characters like . ? + ( ) have special meaning. A dot otherwise matches any character. The tool escapes these characters in your inputs automatically.

What is the difference between a partial and a full match?

Without an anchor an expression matches if it appears anywhere in the text (partial match). With ^ and $ the entire value must match exactly. For “matches RegEx” triggers this is an important difference.

How do I combine multiple paths into one regex?

With the OR operator: (path_a|path_b|path_c). The tool builds this group from your entered values and escapes each value individually.

Can I distinguish URL from Page Path?

Yes – in GTM pay attention to which variable your trigger checks. The full URL contains domain and query, the Page Path only the path. Test your expression against the matching sample values.

Is the regex tester safe?

Yes. Pattern and input lengths are limited and obviously problematic (ReDoS) patterns are caught. No external services are called.

More free tools

View all free tools

These free tracking tools are built by Data Flakes – specialists for conversion tracking, GA4, Google Tag Manager and automation. For custom implementations, audits and consulting we help you directly.