Content groups let you categorize pages and screens into custom buckets. The custom buckets allow you to see metrics for related groups of information. For example, you can create a bucket for pages with men's clothing and another one for pages with women's clothing.
Configure the content group
Google tag (Websites)
To set up a content group using the Google tag, add the content_group
parameter to the web page as follows:
gtag('config', 'TAG-ID', {
'content_group':'<name_of_content_group>'
});
For example, to set up a content group on a page for Men's clothing, you can create a 'mens' content group:
gtag('config', 'G-XXXXXX', {
'content_group':'mens'
});
Similarly, on a page where you show Women's clothing, you could add the following:
gtag('config', 'G-XXXXXX', {
'content_group':'womens'
});
Google Tag Manager (Websites)
You can set up content groups in Google Tag Manager using a RegEx Table variable. The RegEx Table variable will match a regular expression with the URL that someone visits.
Once you create the variable, you can add the variable to a content_group
parameter in your Google Analytics: GA4 Configuration tag.
- In Google Tag Manager, go to Variables on the left.
- In the User-Defined Variables section, click New.
- Click Variable Configuration > Regex Table.
- At the top of the window, rename the variable as "Content Group".
- In the Input Variable field, select {{Page Path}}.
- Add a row to the RegEx Table section.
- Enter a regular expression to identify page path. See an example
- Select Set Default Values.
- Enter "Other group" as the default content group if nothing matches.
- In Advanced Settings, clear the Full Matches Only and Enable Capture Groups and Replace Functionality checkboxes.
- Save your changes.
Step 2: Add the variable to the tag
- In Tags, open your Google Analytics: GA4 Configuration tag.
- In the Fields to Set section, add a row with the content group and variable.
- In the Field Name field, enter "content_group".
- In the Value field, enter {{Content Group}}.
- Save your changes.
- Publish the container.
Example
For example, you want to measure the following page paths on your website:
- Men's clothing page: www.example.com/category/mens
- Women's clothing page: www.example.com/category/womens
Your RegEx table would look like the following:
Pattern | Output |
---|---|
/mens | Men's clothing page |
/womens | Women's clothing page |
Firebase (apps)
content_group
parameter to a screen_view event. Learn moreReport on the content group
To see your content groups, select the Content group dimension in the Pages and screens report or add the dimension in an exploration. For example, the following shows the previously defined content groups in the Pages and screens report:
Configure additional content groups
You may want to set additional content groups. For example, you might want a top-level content group for Men's clothing and then content_group2 for Apparel and content_group3 for Shirts.
To configure additional content groups, create custom parameters for the content groups and then register the content groups as custom dimensions. Learn more