How to Set Up Google Analytics Content Grouping

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.

Each content grouping contains multiple content groups. A content group contains multiple pieces of content.

Each content grouping contains multiple content groups. A content group contains multiple pieces of content.

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.

You can view your content data based on groups, rather than URL, screen name or title.

You can view your content data based on groups, rather than URL, screen name or title.

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.

Content Grouping is a view level setting.

Content Grouping is a view level setting.

Here you will see a list of all your groupings. You can choose to create a new group or edit an existing group.

Here's a list of your Google Analytics content groupings. You can add or edit groupings here.

Here’s a list of your Google Analytics content groupings. You can add or edit groupings here.

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

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]
value:@"Group Name"];

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.

Extraction Method

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:

Your website might use the name of the content in the Page Title or Screen Name dimension.

Your website might use the name of the content in the Page Title or Screen Name dimension.

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.

The content grouping extract method will automatically pull the name for a content group from a dimension of data.

The content grouping extract method will automatically pull the name for a content group from a dimension of data.

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.

Rules Method

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.

The content grouping extract method will automatically pull the name for a content group from a dimension of data.

The content grouping extract method will automatically pull the name for a content group 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.

Content Group methods are applied sequentially.

All three content grouping methods are applied to each piece of content. They are applied sequentially.

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.

Be Sociable, Share!

    Like this post? Sign up to get posts delivered to your inbox.


    1. says

      Hi Justin

      Thanks for writing this post. Couple of things I’ve learnt from setting up some groups.

      1) Make sure you check spellings – once you amend a spelling you’ll end up with two groups in your report. One with the wrong spelling and one with the correct.

      2) Test the groups on a test profile first because the data takes a while to collate in your reports. Well on my profile it did. I’ve heard it’s been pretty quick for some though.

      Look forward to the next instalment.


    2. says

      Cheers Justin, that’s really useful, thanks. I had tried to set this up the other day, but had made a mistake when using the rules based method. Hopefully in a few days this will give me some useful data.

      One quick question – is there any way currently, or is there plans in the future, to add the ability to view behaviour/visitor flow by content groups?

    3. Nastasia says

      I would know what is the syntax for including data related to Content Grouping dimension in a Google Spreadsheet (for example making a filter for a specific content grouping or content group).
      I usually use the Google Automation Report (magic) to make my queries in GA ed export data in Google Spreadsheet.

      Thank you very much

      • says

        @Nastasia – Google Analytics will create a new dimension based on the name of your content grouping. You can extract this dimension using the API. So, if your content grouping is named “My Great Pages” then you should see a dimension with a similar name. I’m actually writing a piece on that and will publish soon.

        Hope that helps!

    4. Nastasia says

      Another question – is it already possible to implement these new feature with Google Tag Manager?

      Thank you

    5. says

      Many thanks for this great article ! I didn’t know this functionnality but i already dreamt about it :) I’ll try to implement as soon is possible…

    6. Les says

      Another great post (and GA feature) Justin. Thanks for this.

      I really like the concept and applicability. What I don’t like is messing with a site’s code when I know that this feature is coming in GTM. So I’ll wait. Until when?

    7. says

      Hey Justin,

      Great post, thanks for sharing this. We’ve been discussing the best way to create a foundation layer of data to report on to clients who produce and promote a lot of content for some time, this looks like a really good place to start,


    8. says

      Great post, really getting to the nitty gritty about using Google Analytics for content. I feel that I have almost got a step by step guide which I am going to be implementing so that I am not creating duplicate data. Also thank you for the tip about adding annotations about when data was added.

    9. Dan Antonson says

      Great post, Justin. Thank you!

      Can you comment a little more on the (future) Google Tag Manager integration with this? Should I wait for that integration before I dive in? I’m curious what you feel the Pros (you’re using the super slick tag manager, of course!) and the Cons are of using GTM to manage content groupings compared to the other methods you’ve outlined?

      I’m assuming manual dataLayers for content groupings be more reliable than using URI rules any way? Or am I mistaken?

      Thoughts? Thanks in advance!

      • says

        @Dan: I can’t get into too many details as things usually change :)

        But the reason I like using GTM is that you can create an implementation that will dynamically change. For example, if you are adding the page category to the data layer, and you launch a lot of new content, then your system should automatically add the correct information to the data layer on the new pages. Then that data can be automatically picked up via GTM and sent to GA. There are other ways to do this – you could use rules, as long as the new content pages are designed in a way that matched existing rules.

        My advice is fairly simple. If you absolutely MUST have content grouping for effective reporting within your organization, and it’s a lot of work right now, then implement content grouping! If not, then you might want to wait for the GTM integration.

    10. says

      Hi Justin,

      Thanks for a great post.

      One thing that I would like to know is: How does Content grouping behaves with the 50,000 unique URLs per day?

      Applying the Rules Method, does the URL has already changed to “(other)”? In this case, I would also lose the grouping.



    11. Alejandro Zielinsky says

      Hello Justin, thanks for the heads up about these changes. Maybe you can help me here if i’m missing something, but I don’t really get what’s the difference between content grouping and creating an advanced segment for specific content.


      • says

        @Alejandro: Creating a content grouping will create an entirely new dimension in Google Analytics. You can then use this dimension in many of the content report, custom reports and dashboards. When you roll-up content using an advanced segment you can only view 4 segments at a time. Whereas with a content grouping you can view the aggregate metrics for up to 50k groups. Hope that clarifies things.

    12. says

      Hey Justin This is really a good and very important info, One quick question what do you think about analytics.js and ga.js i mean which one users should prefer?

      analytics.js is in beta mode so is it good to use this?

      Well thanks for your wonderful stuff keep sharing

      • says

        @Bhavuk: I would use analytics.js. It is the newest, most up-to-date version of the tracking code. The only reason I would NOT use analytics.js is if you need to use the Remarketing feature in GA. That feature does not work with analytics.js YET.

        • says

          Hey Justin, I have implemented Google tag manager code in my website and placed gtm code in body tag, then i checked with tag assistant extension in chrome, it was showing that 2 codes are getting fired from my website webpage than i removed the analytics.js code (GA code) from my website. Is this process correct?
          Now tag assistant is showing that my GTM code is working properly but it is showing one error

          Google Analytics UA-&^*(^%-1

          Error : No http Response detected

          can you tell me what i need to do now?

          one more question, i am tracking all the inbound outbound link activity successfully, but i also want to track social activities on my website, i tried some methods but got fail, Do you have any reference article for doing this?

          • Les says

            By adding the GTM code to your website you negate the need to have the original GA code there. You need to remember to add the GA code to your container in GTM after you have removed the original JS snippet.

            The tag should like this:

            Note that you need to create a firing rule so that the tag fires on all pages.

            To track Social Activities, create a segment that identifies all possible SM properties and apply it to whatever report allows for segmentation. There are some premade segments in the Gallery. I know Avinash made a good one. And I think Justin did also!

    13. Owen says

      In an account with many views (profiles), how do you transfer content groupings between views without having to create them from scratch for every view?

      • says

        @Owen: Unfortunately there is no easy way to transfer a content grouping between views. You’ll need to recreate it – I know, that sucks. I’ve suggested to the team that we add some way to share content groupings. But that may take a while.

        • Les says

          @Justin & @Owen: I do not see how this would make sense as the possibilities with respect to Profiles & Views would make sharing Content Groupings a dog’s breakfast – IMHO. That being said, I like @Owen’s suggestion.

    14. says

      Hi Justin,

      Since there is not documentation out yet (or I couldn’t find it), I would like to ask:

      #1 In your example it’s:

      ga(‘create’, ‘UA-XXXXXXXX-Y’, ‘’);
      ga(‘set’, ‘contentGroup5′, ‘Group Name’);
      ga(‘send’, ‘pageview’);

      Can I execute this with the same success:

      ga(‘create’, ‘UA-XXXXXXXX-Y’, ‘’, { ‘contentGroup5′: ‘Group Name’ });
      ga(‘send’, ‘pageview’);


      #2 What is the byte limit for “Group Name”?

      #3 I don’t quite get the “slot” thing. If a slot is to be tied to a Content Grouping, then why does the GA interface allow me to choose a slot (instead of automatically assign one). Also, why does it allow me to select slot #1 for two different content groupings at the same time?

      • says

        Oh, and I forgot: you say that one and the same page cannot be in more than ONE content GROUP at the same time. Does this mean that it can’t be in more than one content group under a certain slot/grouping, or does this mean that it can’t be in more than one content group regardless of slots/groupings?

        Thanks :-)

      • says


        #1: Yes

        #2: I’m not sure, but you should probably keep it le22 than 255.

        #3: You get 5 slots, and each slot is a single content group. Therefore you can only create 5 content groups when you use the programatic approach. Obviously this is somewhat limiting – but the slots are there to link the data coming from the code to the data in the reports.

        • Alan says

          Thanks for the enlightening post, Justin.

          I’m curious about @Geo’s additional question:

          A page can belong to only one content GROUP within a GROUPING, but can it belong to multiple GROUPINGS?

          That is, can a page can belong to multiple content GROUPS if each group is in a different GROUPING?

    15. Ellen Potma says

      Thank you for explaining this. I now try to implement a test with groupings.. I use rules. But I do not know if these are case sensitive or not. Can you tell me? The Google support page does not tell anything about this.

      • says

        @Victor: Not using the rules-based methods. But you could set up some custom JavaScript that scans the DOM, looks for the appropriate elements, and then sets the content group using JavaScript. Hope that helps.


    1. […] Here’s a useful article that’s sure to come in handy. Google Analytics can get messy and complicated from time to time, so Google have a new way to help organise your content. ‘Content Grouping’ allows users to categorise content in which ever way you want. So instead of just viewing data based on just a page URL, you can group it however you damn well please! Click here to read Cutroni’s detailed guide on setting up this new feature. […]

    Leave a Reply to Justin Cutroni Cancel reply

    Your email address will not be published. Required fields are marked *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>