GA4 Content Groups Regex — GTM RegEx Table Patterns
GA4 does not natively group pages into content groups, so the standard recipe is a Google Tag Manager RegEx Table variable feeding the content_group parameter. This page covers the regex side of that recipe: the default full-match trap (GTM’s checkbox is on by default — the opposite of what most people expect), evaluation order, ready-made patterns and a tester check in your browser before the container goes live.
TL;DR: Variables → New → RegEx Table → Input variable {{Page Path}} (fall back to {{Page URL}} if paths lack category info). Add Pattern → Output rows top-to-bottom (first match wins — put specific rows above catch-alls), press Set Default Value, then in Advanced Settings uncheck Full Matches Only and uncheck Enable Capture Groups and Replace Functionality (leave Ignore Case checked). Wire the variable into the GA4 Configuration tag → Fields to Set → field name content_group, value {{Content Group}}, then Submit the container. Content groups are not back-active — only events after publish appear. Test each pattern in the tester first.
The setup, in one pass
- Variables → User-Defined Variables → New
- Variable Configuration → RegEx Table
- Input Variable →
{{Page Path}}(or{{Page URL}}) - Add rows: Pattern → Output (one group per row)
- Tick Set Default Value and enter
Other - Advanced Settings: uncheck Full Matches Only, uncheck Enable Capture Groups and Replace Functionality, leave Ignore Case checked
- Save, then GA4 Configuration tag → Fields to Set →
content_group={{Content Group}}(or add to your event tags’ parameter set) - Submit (Publish) the container; wait roughly 24-48h for the parameter to populate
The Full Matches Only trap (and its two siblings)
A new RegEx Table variable defaults to exact-string evaluation: /blog/ as a pattern matches the literal /blog/ and nothing else. Clear Full Matches Only and it becomes unanchored substring matching — the behavior every GA4 author expects from a path pattern containing a dash of intentional URL context.
| Setting | Default | What to do | Why |
|---|---|---|---|
| Full Matches Only | checked | uncheck it | Patterns like /blog/ are meant for substring check, anchored variants go explicit: ^/blog/ |
| Enable Capture Groups and Replace Functionality | checked | uncheck it | You are grouping, not transforming; capture groups don’t belong in outputs |
| Ignore Case | checked | leave it | GTM-side regexes are case-insensitive by default (GA4 itself is case-sensitive — the setting at GTM masks that) |
Row order = precedence (first match wins)
GTM evaluates rows top to bottom and stops at the first match. Put narrow, specific patterns above broad ones — otherwise the first broad row buckets everything into itself. The defaults ^/lp/ and ^/landing/ for landing pages both catch /lp/promo-gq; one specific rule above a catch-all keeps both honest.
Ready-made patterns (GTM regex table, Page Path mode)
| Goal | Pattern | Output example | Try |
|---|---|---|---|
| Blog section | ^/blog/ | Blog | tester → |
| Product pages (category or product) | ^/(product|p/)/ | Products | tester → |
| Men’s clothing URLs | /(mens|men-shirts|men's) | Men | tester → |
| Women’s clothing URLs | /(womens|women-shirts) | Women | tester → |
| Docs / help center | ^/(docs|support|help)/ | Docs | tester → |
| Landing pages (campaigns) | ^/(lp|landing)/ | Landing Page | tester → |
| Any explicit section root | ^/ + section word | Section Name | tester → |
| All non-matched URLs | .* (via Default Value, no row needed) | Other | tester → |
Patterns above are simple by design. GTM compiles them with a Google-RE2-compatible flavor (same family Google uses in GA4) — no lookahead, no backreferences. Keep ^/$ anchors for “starts/ends with”, use | alternation for branches, and never end a row with a bare | — the empty alternative matches everything and swallows the rows below it.
A worked example (blog + men/women + Other)
| Page path | Output (Content Group) |
|---|---|
/blog/ga4-utm-parameters/ | Blog |
/category/mens/jackets/ | Men |
/category/womens/bags/ | Women |
/lp/q4-launch-ga4/ | Landing Page |
/pricing/ | Other (default value) |
Debug before you publish
- Paste the pattern + real path into the regex tester; confirm the subgroup it belongs to.
- Order check: mentally run path-by-path — the first row a path touches wins. Move narrow rows up, catch-alls down.
- Untick Enable Capture Groups and Replace Functionality — it only confuses the evaluation.
- Preview your container; change a tracking parameter; confirm
content_groupappears in the GA4 Configuration tag params list. - Publish the container; verify with Tag Assistant / GA4 DebugView (content_group in event params).
- Read it back in GA4: Reports → Engagement → Pages and screens → dimension Content group (or Explore).
Limitations that matter: Content groups don’t look back — they start collecting on publish. You get one content group dimension by default (further ones need extra setup); and derived-from-URL grouping is brittle to site migrations — test after redesigns, not just before launch.
FAQ
Is GTM RegEx Table full match or partial match?
By default it is full match — the Full Matches Only checkbox starts ticked. Clear it and table rows behave as unanchored substring matches (/blog/ then matches /blog/utm-parameters/).
Why is every page in "Other"?
Default Full Matches Only — /blog/ never equals the whole path. Uncheck Full Matches Only (and Enable Capture Groups and Replace Functionality). Also confirm each row ran against the right input variable (Page Path vs Page URL) and the tag sets content_group — nothing else.
Does row order really decide the group?
Yes — GTM evaluates rows top-to-bottom and stops at the first match. Keep patterns strict (^/lp/) above loose (lp) and broad catch-alls (.* never plain row) at the very bottom.
Does a content group apply to historical data?
No. Content groups only know about events fired after publishing; historical reports can’t be back-filled. Publish promptly and values surface within 24-48h.
Works with Pages and screens reports and Explore?
Yes — the Content group dimension appears in Pages and screens and in Explore’s dimension picker, and it applies to every GA4 surface that exposes dimensions. It is not a retroactive rollup: it aggregates events, not rewritten URLs.
Related on RegexLab: GA4 regex match types (matches regex vs partially matches per surface), GA4 page path regex (anchors and query strings), the GA4 regex cheat sheet, GA4 event filter regex, custom channel grouping regex (the session-side sibling of content groups), RE2 vs PCRE and the pattern library.