GA4 Content Grouping: How to Set It Up with Tag Manager

Cover image: GA4 Content Grouping: How to Set It Up with Tag Manager

Content grouping means sorting your pages into a logical structure that reflects how you think about your website or app. It is most useful for larger online stores, blogs and content-heavy sites, where looking at thousands of individual URLs tells you nothing.
To set up content groups in GA4, follow the steps below.

Creating a RegEx Table variable in Google Tag Manager

1. Decide on your group names and define exactly which categories and pages each group should contain.

2. Based on those groups, create a RegEx Table in Google Tag Manager that identifies every page belonging to each group.

To do that, open your Google Tag Manager account and go to Variables.

GA4 content grouping in Google Tag Manager: Variables tab

3. Under User-Defined Variables, click New.

GA4 content grouping in Google Tag Manager: new user-defined variable

4. Click the area labeled Choose a variable type to begin setup…

GA4 content grouping in Google Tag Manager: choose a variable type

5. Scroll down and select RegEx Table.

GA4 content grouping in Google Tag Manager: RegEx Table variable type

6. Name your table variable, for example Content Group.

GA4 content grouping in Google Tag Manager: naming the variable

7. Click Variable Configuration. You will see a section like the one below:

GA4 content grouping in Google Tag Manager: variable configuration

8. In the Input Variable field, pick {{Page Path}} from the dropdown.

GA4 content grouping in Google Tag Manager: Page Path as input variable

If that variable does not exist yet, create it first so the table has something to read.

Now click + Add Row…

GA4 content grouping in Google Tag Manager: add row

…enter your input pattern and output value, then click + Add Row again.

Example input pattern: cocktail|evening|a-line|wrap
Example output value: Dresses

GA4 content grouping in Google Tag Manager: input pattern and output value

If the page path contains any of the words in the input pattern, that page is assigned to the output group.

The ‘|’ symbol works as an OR operator.

9. Enter the remaining input patterns and their output values, for example:

Example input pattern: flared|tulle|denim|leather
Example output value: Skirts

Example input pattern: skinny|joggers|cigarette|boyfriend
Example output value: Pants

GA4 content grouping in Google Tag Manager: several rows in the RegEx table

10. Check Set Default Value and enter Other in the Default Value field. This way, any page whose path does not match any input pattern lands in a group called Other.

GA4 content grouping in Google Tag Manager: default value

11. Under Advanced Settings:

  • leave Ignore Case checked (so the table matches regardless of letter case)
  • uncheck Full Matches Only (so the table performs partial matches)
  • uncheck Enable Capture Groups and Replace Functionality (Google recommends against using it when Full Matches Only is off)

GA4 content grouping in Google Tag Manager: advanced settings

12. Click Save in the top right corner to save the table variable.

GA4 content grouping in Google Tag Manager: save variable

Editing the GA4 configuration tag in Google Tag Manager

1. In Google Tag Manager, go to Tags and click the name of your GA4 configuration tag.

GA4 content grouping: Tags tab in Google Tag Manager

2. Click Tag Configuration.

GA4 content grouping: tag configuration

3. Expand Fields to Set and click Add Row.

GA4 content grouping: fields to set

4. Enter content_group in the Field Name box and {{Content Group}} in the Value box.
{{Content Group}} refers to the table variable you created earlier.

GA4 content grouping: content_group field and variable

5. Click Save to apply the change.

Screenshot: saving the GA4 configuration tag in Google Tag Manager

Checking content group data in Google Analytics 4

1. Wait 24 hours after creating the group before checking the data.
Then go to Reports Engagement Pages and screens.

GA4 content grouping: Pages and screens report

2. Scroll down to the data table and click the Page title and screen class dropdown.

3. Select Content group.

The report now shows data broken down by your content groups.

Content groups only make sense when the structure mirrors how your customers actually buy. If the reports show data you cannot act on, the problem is usually the configuration, not the tool. That is one of the things we check in a marketing audit.