Content groups in Google Analytics

If there is an unsung hero in Google Analytics, it is definitely something called content groups (or content grouping). Never heard of it? It is hiding in plain sight, in your Google Analytics view settings, and can be set up in a couple of clicks. Once content groupings are set up, you will always want to use them 🙂

Ready? Get some coffee, snacks, and let’s go build some content groups.

What are content groupings in Google Analytics and what do they do?

Simply put, content grouping allow you to create… wait for it… groups of content 🙂 Many times you will want to see consolidated reports on multiple elements and dimensions without having the possibility to see them grouped together as one entity.

Imagine you run a bilingual site like this blog but don’t necessarily have the URL structure to distinguish between languages. Imagine you run a news site made up of content sections such as politics, finance, sports, culture, etc. Imagine you run an e-commerce site with departments and product categories.

In the case of the multilingual blog, I want to see an overall view of my content’s consumption in terms of language.

In the case of the news site, I want to see which sections were read the most and which were read next.

In the case of the eCommerce website, I want to see whether my users are browsing within the same product category or exploring other products.

Creating content grouping

First things first, go to your Google Analytics admin panel and locate your view, as shown below:

You should be seeing an empty table, but I’ll show you how mine looks in the test view we’ll be playing with:

List of content groupings in Google Analytics

As you can see in the example above, I’m using up all 5 content groups allowed per Google Analytics view. I can create more groupings in another view if needed.

In your case, you should have a big red button called New Content Grouping . Click it. CLICK IT NOW.

The first thing we’ll do is give the new content grouping a name. If we use the eCommerce website example, let’s imagine it’s a clothing store – with 3 major sections: women’s clothing, men’s clothing and children’s clothing. With that in mind, let’s name the new content grouping Product section.

Next, I have to choose from three options in order to give my content grouping a value:

  1. Group by tracking code: relies on what information is sent to the Google Analytics tracking call, using Google Tag Manager for instance. This implies your tracking code / data layer includes the information required, with a productSection dataLayer entry for instance. Probably the safest option, assuming you can handle the related development.
  2. Group using extraction: here we’ll be looking at patterns in URLs and capture the strings in the URLs that match the pattern. Expect to use regular expressions 🙂
  3. Group using rule definitions: with this option we can specify a value that applies when conditions are met, based on URL, page title or screen name. Basic but powerful, assuming you’re ready to handle lots of unique cases.

Actually, let’s tackle them in reverse order!

Group using rule definitions

This is going to be the most common way you use content groupings. Why? Because accessing your site’s URLs is the easiest way to find patterns and use them to create logical groups.

For instance, If we want to give our Product section content grouping a value based on URL rules, we can create a new rule. As shown below, we are creating a value of “Kid’s clothing” for pages where the URL contains /kids or /children. Yes, you can use regular expression as well as AND and OR conditions, which make rule creation a breeze.

Creating content grouping in Google Analytics based on rule definition

Another example is what I use to measure how much content on my site is served as AMP.

The above definition means I can now look into my Behavior > Site Content > All Pages report and use my content grouping as the main dimension:

Using a content grouping as main report dimension

Then once you select your content grouping (AMP in this case), your report shows you that consolidated view you’ve been waiting for:

Neat, right?

Group using extraction

We got the fun part done with the previous grouping method but the extraction method can be interesting too! In the example below, we use a regular expression to capture part of the URL folder structure that immediately follows the /products/ folder. In our case we assume URLs in the form of /products/mens/shirts.html. As with regular expressions, whatever sits inside the parentheses is captured to be used later. If the regexp is set to /products/(.*)/.*.html and using the above test URL, we’re going to captures mens and store it as the value for our content grouping.

Sounds straightforward, yes? Good – now for the best bit 🙂

Group by tracking code

Grouping by tracking code is a lot more elegant, especially if you work with a tag management system such as Google Tag Manager. Essentially, you need to select your content grouping’s number (index) from 1 to 5 and pass a value to it.

Let’s examine the Google Tag Manager methodology. Assume you can generate the following data layer for any given page:

var dataLayer = window.dataLayer || [];
dataLayer.push({
  "productSection": "Men's clothing"
});

In Google Tag Manager, create a variable based on your productSection data layer variable:

Next, in your Google Analytics page view and event tags (or even in your Google Analytics configuration variable), setup your content group to use your new variable:

Using Google Tag Manager variables to populate content groupings in Google Analytics tag

Publish your GTM container and voilà! You have an elegant solution for content grouping that does not rely on URL-based rules and can easily integrate with your content management system.

But wait, don’t we have custom dimensions for that?

Ah, an astute remark! Custom dimensions are indeed available for a similar purpose, with the addition of specific scopes (user, session or hit), whereas content groupings are hit-based. Furthermore, custom dimensions are pretty much expected to be set in the tracking call, whereas content groupings can be set using URL rules, extraction, or tracking code, making them a bit more flexible than custom dimensions.

As mentioned before, the main advantage of content grouping over custom dimensions is pathing. You can see how content grouping can be included in a flow-type report:

If I use my content publication year content grouping, I can see if users navigate from older to newer posts or the other way around:

Using content groupings as high level navigational elements

Of course this method works great with the news site or ecommerce site examples I mentioned earlier.

In closing

If you hadn’t heard about content grouping in Google Analytics before this post, something tells me you’ll be using them very soon 🙂

If you’ve used them before, is your setup similar to my suggestions? Let me know in the comments!

Author: Julien Coquet

Expert de la mesure d’audience sur Internet depuis plus de 15 ans, Julien Coquet est consultant senior digital analytics et responsable produit et évangélisation pour Hub’Scan, une solution d’assurance qualité du marquage analytics. > A propos de Julien Coquet

8 thoughts on “Content groups in Google Analytics”

  1. Big drawback: they are at the View level, so if you define a bunch of them in a view, you have to start over in the other views. Any recommendation?

    1. Hi Jacques, thanks for the feedback!

      EDIT: the GA API team confirmed content grouping will not be developed over the API, as was originally hinted at
      Content groups are manageable en masse via the Google Analytics Management API to be applied to a large number of views if needed.
      Not optimal but fairly scalable.

        1. Hi Sebastian,

          I had a chat with the API team back in the day that wasn’t definitive about not including content groups. But that was then and I haven’t updated my post since then.

  2. Hi Julien,

    Great post, I noticed that there is an ability within a content group to mix the three different options. How does that work? I tried to use this to fill gaps in my code enabled grouping (due to legacy pages…) and it does not appear to work. It creates a grouping with description “Tracking Code Enabled > 1 Extraction” but the content does not appear to be modified at all. I still see a lot of “unassigned”.

    I was hoping to be able to make this change within Google Analytics as getting configurations changed within the code at my company is a bigger endeavor.

    Thanks

  3. Hello,
    I use only tracking code to create my content groups but i have an issue.

    For example, I assigned a page to content group 1, and this page has 300 views in the group but this same page is also in “not set” with 1000 views “.

    Only part of the page traffic is picked up by the group and the biggest part is in “not set”.

    Any idea to solve this problem?

    Thank you in advance for your answers 🙂

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.