[UA] Create/edit Content Groups [Legacy]

You are viewing a legacy article about Universal Analytics. Learn more about Google Analytics 4 replacing Universal Analytics.
This article is about creating and editing content groups in Universal Analytics. For information about creating content groups in Google Analytics 4, go to [GA4] Create content groups.
You must have the Editor role for the view in which you want to create a Content Group.
In this article:

Overview

You first create a top-level Content Grouping, and then within that, create individual Content Groups by one of the following methods:

  • Modify the tracking code on each page you want to group
  • Extract pages with regex capture groups
  • Create rules to include pages in a group

Analytics processes the tracking code first, then the regex, and then the rules. As soon as it finds a match, the processing ends, and your content is grouped according to that first match.

Say, for example, that you have a site that sells clothing for men and women, and your general categories of clothing are:

  • Men
    • Shirts
    • Pants
    • Accessories
  • Women
    • Tops
    • Slacks
    • Skirts & Dresses
    • Accessories

Given those product lines, you may want to conduct the following types of analysis:

  • Compare overall sales between Men and Women
  • Compare sales among the product lines within Men and Women

Given the kind of analysis you want to conduct, you could create the following Content Groupings, and within those, the following groups:

Compare Men and Women:

  • Content Grouping: Clothing
  • Content Groups: Men and Women

Compare product lines within Men:

  • Content Grouping: Men
  • Content Groups: Shirts, Pants, Accessories

Compare product lines within Women:

  • Content Grouping: Women
  • Content Groups: Tops, Slacks, Skirts & Dresses, Accessories

With the configuration above:

  • Clothing, Men, and Women are options in the Primary Dimension > Content Grouping menu.
  • When you select Clothing as the primary dimension, Men and Women are the dimension values in the first column of the report table.
  • When you select Men as the primary dimension, Shirts, Pants, and Accessories are the dimension values in the first column of the table.
  • When you select Women as the primary dimension, Tops, Slacks, Skirts & Dresses, and Accessories are the dimension values in the first column of the table

For each dimension value (Content Group), you see behavioral metrics like Pageviews and Bounce Rate.

When you drill in to a Content Group, you see behavioral metrics for each page in that group.

Create a Content Grouping

You can create up to five Content Groupings.

You cannot delete a Content Grouping. You can change the definition or turn it off.

  1. Sign in to your Analytics account.
  2. Click Admin, and navigate to the view you want.
  3. In the VIEW column, click Content Grouping.
  4. Click +New Content Grouping.
  5. Enter a name for the new grouping.
  6. Select the methods you want to use (tracking code, extraction, or rules) to create Content Groups.
     

Create a Content Group via the tracking code

  1. Under GROUP BY TRACKING CODE, click Enable Tracking Code.
  2. Make sure the Enable option is set to On.
  3. Select an index number (1-5) to identify your Content Grouping.
  4. Click Done.

When you modify your tracking code, you use an index number (1-5) to identify the Content Grouping, and you use a group name to identify your Content Group:

  • gtag.js: gtag('config', 'GA_TRACKING_ID', {'content_group<Index Number>': '<Group Name>'});
  • analytics.js: ga('set', 'contentGroup<Index Number>', '<Group Name>');

For example, if you configure a Content Grouping for Clothing identified by the Index Number 1, and within that you create a Content Group called Men, you would update your code as shown:

  • gtag.js: gtag('config', 'GA_TRACKING_ID', {'content_group1': 'Men'});
  • analytics.js: ga('set', 'contentGroup1', 'Men');

For each contentGroup or _setPageGroup call, you can identify only one Index Number - Group Name pair.

Follow the highlighted example for your implementation method:

Modify your gtag.js snippet

Modify your tracking code to include the content group parameter and value as shown in the example below:

<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script>
<script>
   window.dataLayer = window.dataLayer || [];
   function gtag(){dataLayer.push(arguments);}
   gtag('js', new Date());
 
   gtag('config', 'GA_TRACKING_ID', {'content_group5': '/news/sports'});
</script>
Modify your analytics.js snippet

Modify your tracking code to include a call to the _set function just before calling _send, as shown in the example below:

<script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-XXXXXXXX-Y', 'example.com');
ga('set', 'contentGroup5', '/news/sports');
ga('send', 'pageview');

</script>
Modify your Android-SDK snippet
Tracker tracker = GoogleAnalytics.getInstance(this).getTracker("UA-XXXX-Y");
tracker.set(contentGroup(5), "/news/sports");
Modify your iOS-SDK snippet
id tracker = [[GAI sharedInstance] trackerWithTrackingId:@"UA-XXXX-Y"];
[tracker set:[GAIFields contentGroupForIndex:5]
value:@"/news/sports"];

You need to make this code modification to each page you want to include in a Content Group.

Once you have updated your pages with the tracking code, those pages are then grouped according to how you identified them by index number and group name.

If you call the same index number multiple times on the same page, then only the last call for that index number is sent to Analytics.

Any page that does not contain the _setPageGroup function is included in the (not set) Content Group.

Assign content via extraction

You can extract pages by Page URL, Page Title, or Screen Name. Identify each one with a regex capture group (Analytics uses the first capture group for each expression).

Click Add extraction, then select either Page URL, Page Title, or Screen Name.

In the field to the right, enter the value you want to match. For example:

  • Page > /Men/(.*)/
    • Creates a Content Group for each subdirectory of /Men/, and adds the pages in each subdirectory to the corresponding Content Group
  • Page Title > (.*shirts).*
    • Creates Content Groups for pages that contain the word shirts

      For example, if your site has the following directories with shirts pages:
      • /men/m_dress_shirts.html
      • /men/m_tshirts.html
      • /boys/b_dress_shirts.html
      • /boys/b_tshirts.htm.

      Then you would have the following Content Groups and pages within those:
      • men (m_dress_shirts.html, m_tshirts.html)
      • boys (b_dress_shirts.html, b_tshirts.html)
  • Screen Name > (.*pants).*
    • Creates Content Groups for screen names that contain the word pants

When you have configured the extraction, click Done.

See more examples of using regex capture groups to extract content.

Assign content via a rule set

If you use this option, you create rules to assign content.

To open the rules editor, click Create a rule set.

For each rule:

  1. Enter the name you want to use for the Content Group.
  2. Under Define rules, select either Page URL, Page Title, or Screen Name.
  3. Select a matching option and enter a value to match. For example:
    • Page > contains > /Pants/
      • Adds all pages that have /Pants/ in the URL to the Content Group
  4. Click OR or AND to add an OR or AND condition to the rule. Follow the instructions above to define the additional condition.
  5. When you have defined all the conditions you want to use, click Done.
  6. After you finish all your configuration for the group, click Save.

Naming: case sensitivity and effects on historical data

Case sensitivity

Content Group names are not case sensitive. For example, if your rule defines a content group as:

Page exactly matches /Google+Redesign/Apparel

then that rule will match any form of that page name. For example:

  • /Google+Redesign/Apparel
  • /Google+Redesign/apparel

Effects on historical data

If you change the name of a Content Grouping, there is no effect on historical data: all data will immediately appear under the new name of the Content Grouping.

If you change the name of the rule that defines a Content Group, then data from that point forward appears under the new Content-Group name, and data from before the name change appears under the old name.

Content Grouping name, Content Group rule name.

Was this helpful?

How can we improve it?
true
Choose your own learning path

Check out google.com/analytics/learn, a new resource to help you get the most out of Google Analytics 4. The new website includes videos, articles, and guided flows, and provides links to the Google Analytics Discord, Blog, YouTube channel, and GitHub repository.

Start learning today!

Search
Clear search
Close search
Main menu
13642288448892627497
true
Search Help Center
true
true
true
true
true
69256
false
false