Search
Clear search
Close search
Google apps
Main menu

Create/edit Content Groups

To must have Edit permission for the view in which you want to create a Content Group.

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

  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 Create 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:

  • analytics.js: ga('set', 'contentGroup<Index Number>', '<Group Name>');

For example, if you’re configuring a Content Grouping for Clothing identified by the Index Number 1, and within that creating a Content Group called Men, you would have the following:

  • analytics.js: ga('set', 'contentGroup1', 'Men');

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

The tracking-code modification is only a single line in the Analytics tracking code on each of your web pages or app screens.

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', '<Group Name>');
ga('send', 'pageview');

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

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
    • Examples

      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.
Was this article helpful?
How can we improve it?
Google Analytics training and support resources

Check out our comprehensive list to learn more about Analytics solutions.