Create/edit Content Groups
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:
- Skirts & Dresses
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
- Sign in to your Analytics account.
- Click Admin, and navigate to the view you want.
- In the VIEW column, click Content Grouping.
- Click Create New Content Grouping.
- Enter a name for the new grouping.
- Select the methods you want to use (tracking code, extraction, or rules) to create Content Groups.
Create a content group via the tracking code
- Under GROUP BY TRACKING CODE, click Enable Tracking Code.
- Make sure the Enable option is set to On.
- Select an index number (1-5) to identify your Content Grouping.
- 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:
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:
ga('set', 'contentGroup1', 'Men');
_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:
ga('create', 'UA-XXXXXXXX-Y', 'example.com');
ga('set', 'contentGroup5', '<Group Name>');
Tracker tracker = GoogleAnalytics.getInstance(this).getTracker("UA-XXXX-Y");
tracker.set(contentGroup(5), "<Group Name>");
id tracker = [[GAI sharedInstance] trackerWithTrackingId:@"UA-XXXX-Y"];
[tracker set:[GAIFields contentGroupForIndex:5]
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
If your site has the following directories with shirts pages:
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:
- Enter the name you want to use for the Content Group.
- Under Define rules, select either Page URL, Page Title, or Screen Name.
- 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
- Page > contains > /Pants/
- Click OR or AND to add an OR or AND condition to the rule. Follow the instructions above to define the additional condition.
- When you have defined all the conditions you want to use, click Done.
- After you finish all your configuration for the group, click Save.