Today everyone is creating content – lots and lots of content. Measuring that content can be a challenge given the sheer volume that’s out there. That’s where Google Analytics Content Grouping can help.
This feature let’s you categorize your content based on your own business rules. Then, rather than view your data based on page URL or screen name, you can view based on your specific groups.
In this post I’m going to talk about how content grouping works and how you set it up.
Key Vocabulary: Groupings and Groups
There is a little terminology we need to cover before we get into the setup: groupings and groups.
You can create multiple content groupings in Google Analytics.
Within a grouping you can create multiple content groups.
A group is a collection of content. It could be pages in a certain section of your website. Or it might be screens from a certain part of your app. It can be just about anything.
A grouping is just a bunch of groups.
You can create multiple content groupings in Google Analytics and switch between them in the reports.
Here’s an example. For my blog I created a grouping called Blog Content Categories.
Within that grouping I create a number of groups to categorize the different types of content on my blog. There’s a group for posts, a group for about me pages, a group for error pages, etc. In the configuration I created a rule that puts each page in a group based on the structure of the URL.
Any item that is not added to a group will appear in the
(not set) content group.
It’s important to know that there is not one specific report where you access this data. When you create a grouping it’s literally becomes a new dimension of data. You choose to view that dimension in almost all of the content reports.
Let’s take a look at how you actually create a grouping and groups.
Creating Groupings & Groups
Google Analytics does not automatically create content groupings – you must configure the tool to do that. Navigate to the settings for a specific view and choose Content Groupings.
Here you will see a list of all your groupings. You can choose to create a new group or edit an existing group.
There are three methods you can use to create a content group – let’s take a look at each.
Tracking Code Method
This method requires you to add a small piece of code to each page on your site or in your app. The code will literally set the name of the content group when the page or screen renders. Here’s how the code would look for Universal Analytics:
ga('create', 'UA-XXXXXXXX-Y', 'example.com');
ga('set', 'contentGroup5', 'Group Name');
Or, if you’re working in iOS the code might look like this:
id tracker = [[GAI sharedInstance] trackerWithTrackingId:@"UA-XXXX-Y"];
[tracker set:[GAIFields contentGroupForIndex:5]
The code for a content group is similar to the code for a custom dimension. You can set 5 content groups using the tracking code. Each group is associated with a number, one through five, as shown in the example above.
Check the Google Analytics support documentation for more code examples.
Basically this method let’s you suck in the group name, via code, from some other system. It might be a CMS, a data layer, or just the HTML of the page.
The key is that you somehow add the name of the group to the Google Analytics code.
Pros: Using the tracking code method you can use code to automatically adjust to changes in your content and new content groups.
Cons: It requires IT involvement to set up. But once it’s configured very little IT support.
I should also mention that content grouping is coming to Google Tag Manager. This will provide another way to programmatically set the content group – so stay tuned.
The extraction method extracts (get it) the name of your content groups from an existing dimension of data. The idea is that you use a regular expression to parse the dimension and automatically extract the name of your group.
For example, the name of your content groups might be in the page title, like this:
I would need to specify that my group name is in the Page Title dimension, and then provide a regular expression that extracts the appropriate value.
For those of you that do not use regular expression, the value in the parenthesis will automatically be extracted. Google Analytics will then use the value as the group name.
You can see that this one rule will work for every product page on my site – as long as they are well formatted.
Pros: No coding involved. Flexible collection.
Cons: You might need to update your regular expressions when you add new content to your site or app. Specifically something that does not match your existing rules. Believe me – updating settings SUCKS. People forget to do it all the time.
In you’re new to regular expressions check out this reg ex tutorial in the Google Analytics help center.
The rules method is almost exactly like the extract method. The ONLY difference is that you have to MANUALLY name the group. The value for the name is not automatically pulled from a dimension of data.
Like the extract method you can create rules based on different dimensions of data- the page title, page url or the screen name. If the dimension value matches the rule then the content is added to the group.
Pros: No coding. Don’t need to know regular expressions.
Cons: You need to remember to update your rules when you add new content or if your site urls or app screen names change. Again – updating your analytics settings SUCKS. People forget to do it all the time.
Which method should you use?
That’s a tough question. Personally, I think page category is a critical piece of data that should be added to a page data layer. If you take this approach then using the tracking code method is very scalable.
I also like the extract method. It’s very flexible and reliable – as long as you have processes in place to maintain your implementation :)
Important things to know
Ok, so here are a few very important things to know.
You can use all three methods for creating groups within the same content grouping.
The grouping logic is applied to your data sequentially. That means that Google Analytics first applies the tracking code method first. Then it applies the extraction method. And finally it applies the rules method. You can use all three methods for your implementation.
When a page or screen matches a rule it is added to that group.
A page or screen can only be in ONE content group at a time! That means that an page or screen can only belong to one group at a time.
And finally, content groups are NOT applied to historical data. They are only applied from the moment you configure the feature.
A Best Practice
Because Google Analytics applies all grouping methods to your data, it is possible to use a combination of grouping methods.
But, because they they are applied SEQUENTIALLY, it’s a good idea to put your very specific grouping rules first, followed by your general rules. This way the later, general rules will catch anything that slips through the early, specific rules.
It’s really, really important to try and get your groups right the first time. While you can edit your groups, there is no way to change the data that has already been processed.
Make sure you test your groups first before announcing them to your entire team.
It’s also a good idea to add an annotation to Google Analytics so everyone knows when the data was added.
Ok, I think that’s it for how to implement this feature.
Don’t worry – I’ll explain how to use content groups in a couple of days.