Content groups enable you to categorize pages and screens into custom buckets so you can see metrics for related groups of information.
For example, you can create separate buckets for pages that display men's, women's, and children's clothing.
Set up a content group
Use the following drop-downs to see information about how to set up a 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('set', '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('set', 'content_group', 'mens');
Similarly, on a page where you show Women's clothing, you could add the following:
gtag('set', 'content_group', 'womens');
You can also set the content_group
parameter using the page_view
event or set
command.
To learn more about the content_group parameter, see the Configuration reference.
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 |
Google Analytics for Firebase (Mobile apps)
content_group
parameter to a screen_view event. Learn moreSee content groups
You can see your content groups by selecting the Content group dimension in the Pages and screens report or selecting the dimension in Explorations.
For example, the following shows the content groups defined in the previous example in the Pages and screens report:
When you don't set a content group, Analytics populates the Content group dimension with (not set).
Set 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.
You can set additional content groups by creating custom parameters for the content groups and then registering the content groups in Analytics as custom dimensions.