In this guide, I’ll explain what content groups are and how to create content groups step-by-step. It might sound a bit technical, but don’t let that intimidate you. You can follow the steps below and hardly need any technical knowledge to set up content groups.
Table of contents:
What are content groups? How to set-up content groups via GTM? Where to find the content group data in GA4?What are content groups?
Content groups are collections (buckets) of certain pages on your website that are related to each other. This allows you to easily see how many visitors are active on a specific section of the website and compare these groups with one another. It’s a useful feature, for example, for multilingual websites, webshops with multiple product categories, or websites with a knowledge base/blog featuring various themes.
How to set-up content groups via GTM?
Step 1: Create a RegEx Table in Google Tag Manager
1.1. Go to Google Tag Manager and navigate to ‘Variables’. Click ‘New’ in the ‘User-Defined Variables’ section.
1.2. Enter a name for use within GTM. For example: RegExTable – Content groups
. Then click on the ‘Variable Configuration’ block.
1.3. Select the variable type ‘RegEx Table’.
1.4. Choose the desired ‘Input Variable’. This will be the variable on which the Regular Expression is executed and which determines the output. The choice of variable depends on the desired categorization and the available variable values, but I often use {{Page Path}}.
1.5. Click ‘Add Row’. You will now see two fields: ‘Pattern’ and ‘Output’.
- In the Pattern field: enter your Regular Expression: e.g.,
men\-hoodies
.- The
\
and-
are not operators. The\
is used to escape the-
, ensuring GTM interprets the hyphen as text. If you use special characters, add a\
(backslash) before them - Tip for non-technical users: Keep it simple and avoid using many operators.
- A brief explanation: If you only input
men
, GTM will check if the textmen
appears in the Input Variable. If you inputmen|women
, GTM will check if eithermen
orwomen
appears. - Want to test your RegEx? Do so via Regex101.com instead of GTM.
- The
- Enter the name of the content group in the Output field, e.g., Men’s Clothing.
1.6. Repeat step 1.5 as needed, depending on the number of groups/buckets you want to create.
1.7. Check ‘Set Default Value’.
1.8. Enter ‘Other group’ or ‘Miscellaneous’ as the default value. This will be used if none of the Regular Expressions match.
1.9. Click ‘Advanced Settings’. Uncheck ‘Full Matches Only’ and ‘Enable Capture Groups and Replace Functionality’. By disabling Full Matches Only, GTM checks if the Pattern appears in the Input Variable, even if it doesn’t match completely.
1.10. Click ‘Save’ in the top-right corner.
Step 2: Add the content_group parameter to pageviews
2.1. Go to Google Tag Manager and navigate to Tags.
2.2. Select your GA4 Configuration Tag (if you don’t have one, create it first).
2.3. Add a row under ‘Fields to Set’ with content_group
as the Field Name and {{RegExTable – Content groups}} as the Value.
2.4. Click ‘Save’ in the top-right corner and don’t forget to publish the container (and test to ensure the data appears correctly in GTM and GA4).
Note: You can also send multiple content groups (e.g., content_group2
, content_group3
, etc.).
Step 3: Add the content_group parameter to events
You can also send the content_group
parameter with events. To do this, make sure to create a content_group
event parameter (custom dimension for events) in GA4.
3.1. Go to Google Tag Manager and navigate to Tags.
3.2. Select the GA4 event tag to which you want to add the parameter.
3.3. Add a row under Event Parameters with content_group
as the Parameter Name and {{RegExTable – Content groups}} as the Value.
3.4. Click ‘Save’ in the top-right corner and publish the container (and test to ensure the data appears correctly in GTM and GA4).
3.5. Repeat these steps for each event.
Step 4: Create a custom dimension in GA4
In my previous blog, I explained how to add an event parameter in GA4. Follow that guide to create a custom dimension with Content group as the Dimension name and content_group
as the Event parameter. This allows you to capture the content_group
parameter sent with events.
Where to find the content group data in GA4?
In GA4, you’ll find the content group parameter in most reports once you’ve created a custom dimension and sent the content_group
parameter with events. If you haven’t done this yet, you’ll already see content group data by default in the Pages and Screens report (under Engagement). You can also use the content group dimension in other tools like Looker and BigQuery.