How to Set Up & Use GA4 Content Groups

Learn GA4 content grouping the easy way - no developer needed. We'll show you how to set up content groups in GTM & the benefits of using content groups in GA4.

Friday, March 31, 2023
Updated:
GA4 content group setup using GTM

Key takeaways:

  • Content groups are collections of related website pages. 
  • You can create custom content groups in GA4 based on whatever criteria you like. 
  • In GA4 you can group content using the Google global site tag or Google Tag Manager. This article explains how to group content in GTM without working with a developer.
  • Creating content groups lets you analyze website performance in new ways.

What Is a Content Group?

A content group is any collection of website pages you decide to group together. You can create one or multiple content groups to use in GA4 reports.

Content grouping is a technique that lets you compare collective web page metrics by group name so you can analyze the performance of specific sections of your website. Then you can quickly see which types of content are generating the most entrances, pageviews, engagement, and/or conversions.

Ecommerce content group examples

  • Product categories, e.g. women’s running shoes vs. men’s running shoes
  • Different brands 
  • Products at different price tiers

Non-ecommerce content group examples

  • Blog pages vs. all other website pages
  • Different types of page templates/design layouts
  • Different website topics, no matter what kind of page it is

The sky is really the limit when deciding how to group your content. You get to decide the grouping rules based on the insights you want. You should put some thought into your content groups before creating them. If you go back and edit your content grouping it will change the definition of the group (including the default/ungrouped group) which will make month-over-month and year-over-year comparisons less accurate. Define content groups based on factors inherent to the web page, like page type, category, or topic.

Content Groups vs Segments in GA4

If you’ve ever thought, “I wonder if our blog posts with videos have a longer engagement time compared to blogs without videos?” or “Do our pages with structured data get more entrances from organic search?” -those are examples of questions better answered by applying a segment. GA4 segments can only be used in Exploration reports, but they'll give you the same kind of on-the-spot filtering you can get from custom segments in UA. Segments are a better option for filtering web pages based on things that can change more easily, such as page elements, structured data markup, or how recently the content was updated.

Content Group Page Paths

GA4 relies on page paths for content grouping. 

<div class="post-note-cute">The page path is the part of the URL after the domain. Page paths are nothing new in Analytics, they’re just labeled as “Page” in UA and “Page path” in GA4.</div>

URL example with domain and page path labeled

Content grouping by page path is super convenient if your pages are all organized within subfolders that contain descriptive keywords:

/blog/movie-reviews/jurassic-park

/blog/movie-reviews/hunger-games

/blog/movie-reviews/lord-of-the-rings

/blog/book-reviews/jurassic-park

/blog/book-reviews/hunger-games

/blog/book-reviews/lord-of-the-rings

/products/shoes/women/running-shoes

/products/shoes/women/cross-training-shoes

/products/shoes/women/basketball-shoes

/products/shoes/men/running-shoes

/products/shoes/men/cross-training-shoes

/products/shoes/men/basketball-shoes

URLs like the above examples make it easy to group content using page path. For example, you could define a content group as “any URL that has movie-reviews in the page path”, or “any URL that has men/running-shoes in the page path” (which would include the URLs for all product pages within the men’s running shoes category).

But the content groups you define may or may not mirror how content is grouped in your CMS or in your website navigation. It depends how your URL structure is set up, and how you think about the different sections of your website. 

If your pages aren’t organized well in the CMS, or if you want to compare groups of content based on factors other than category/topic, then you’ll have to do more work to group them. It’s not complicated, it just takes more time.

How to Set Up GA4 Content Groups in Google Tag Manager

Once you’ve decided how you want to group your content, there are just 2 steps to setting up a GA4 content group in GTM:

  1. Create a RegEx Table variable
  2. Add that variable to a content_group parameter in your GA4 Configuration Tag

If you’re not familiar with regex or GTM variables, don’t worry: we’ll show you exactly what to do, and it’s not as complicated as it might sound.

Step One: Create a RegEx Table Variable

If you’re grouping URLs that all have the same keyword in the page path, you don’t even need to learn about regex. For example, on Momentic’s website every blog about GA4 includes “ga4” in the page path. So we can just use ga4 to define the group.

<div class="post-alert">Make sure there aren’t other website URLs that contain the keyword you’re filtering for, or there will be unwanted pages in your content group.</div>

But if you’re grouping pages that don’t all have the same keyword in the URL, then you’ll need to create a regex to define the group.

<div class="post-note">RegEx (Regex, regex, regexp) is short for regular expression. A regular expression is a command written as a sequence of special characters and plain text. A Regex works like a filter so software (like GTM) can fetch the specific data you want.</div>

There’s plenty more to learn about regular expressions and metacharacters used in Analytics applications. For the purposes of this article, we’re just going to use a very simple one:

| (pipe) means “or”

Using the same example, let’s say some of Momentic’s GA4 blog posts have google-analytics-four in the page path instead of ga4. In that case we’d use the pipe to include both keywords:

ga4|google-analytics-four

^^This regex tells GTM to fetch all page paths that include ga4 OR google-analytics-four. 

<div class="post-note-cute">Content grouping really drives home the importance of thoughtful and consistent URL naming conventions. Keep that in mind when creating new pages!</div>

But what if you want to group pages that don’t have a common keyword in their page path? In that case you have to list all the page paths you want in the group, with pipes in between them.

If you’re only grouping a few pages, you can just manually copy and paste the page paths into a regex:

exmple page paths expressed as a regex pattern

^^In this example the regex pattern is telling Tag Manager: “If the page path contains any of these strings of text, make that page part of this content group.”

But if you want to group a lot of pages with no single common page path keyword, you should use specialized tools to save time:

  • Site crawler to export URLs
  • Regex builder to create & test patterns
  • AI tools that can write regex for you

Now that we’ve covered the regex basics, here’s how to create a Regex Table Variable in GTM:

<div class="post-action">Click on Variables in the left-hand menu.</div>

Google Tag Manager Variables

<div class="post-action">Scroll down to the User-Defined Variables section. Click New.</div>

<div class="post-action">Click Variable Configuration, then scroll down and click Regex Table.</div>

choosing RegEx Table variable type in GTM

Give your Untitled Variable a name. I suggest “Content Group”.

<div class="post-action">Click Input Variable and choose Page Path from the drop-down menu.</div>

<div class="post-action">Click Add Row. This is how you build the Regex Table, one row at a time. ‘Pattern’ is one column and ‘Output’ is another column. Enter your specification for one content group under Pattern. Then enter a descriptive name under Output - this will be the name of your content group in GA4.</div>

GTM RegEx Table variable configuration

If you want to create multiple content groups, just click Add Row again and keep going. You can also come back another time and edit this variable.

<div class="post-action">Check the box next to Set Default Value and enter a name - this will be the name of the default content group in GA4, which is a catchall for the pages that don’t belong to any of your defined content groups. It can be “Other” or “Ungrouped” or whatever you like.</div>

GTM RegEx Table Variable default value set to 'Other'

<div class="post-action">Click Advanced Settings. Uncheck the boxes for “Full Matches Only” and “Enable Capture Groups and Replace Functionality”.</div>

GTM RegEx Table Variable advanced settings

<div class="post-action">Click the blue Save button in the upper right.</div>

Step Two: Add Your RegEx Table Variable to the GA4 Tag

Now go to the left-hand menu again and click Tags. Find your GA4 Configuration Tag and click that.

<div class="post-action">Click Tag Configuration to edit the tag. Open the Fields to Set section. Click Add Row.</div>

Enter content_group under Field Name and {{Content Group}} under Value.

GA4 configuration tag with content group variable added

Save the changes to the GA4 Configuration Tag, then Submit the workspace changes.

submitting workspace changes in GTM

That’s it! Now you just have to wait 24 hours for the content group(s) you defined to show up in GA4. The value for the Content group dimension will display as (not set) until it's ready.

Reporting on Content Groups

There are two immediately accessible ways to view your content groups in GA4. You can also create a custom dimension for content groups.

<div class="post-note">Content group data is not available retroactively in Google Analytics, only going forward.</div>

Pages and screens report

<div class="post-action">Go to Reports > Engagement > Pages and screens. Choose ‘Content group’ from the dimension dropdown.</div>

Content group dimension in GA4 Pages and screens report

In this example we’re seeing only two of the three content groups because it’s been less than 24 hours and there haven’t been any views in the third content group yet. We’re also seeing (not set) because the date range includes time before the content groups were set up.

Using Content Groups in Explorations

<div class="post-action">Go to Explore, then choose an existing Exploration or create a new one. Inside an Exploration, click the plus sign next to Dimensions.</div>

Adding dimensions to GA4 Explorations report

<div class="post-action">Search or scroll down and select Content group. Click Import.</div>

Adding content group dimension to GA4 explorations report

Now you can use the Content group dimension in your exploration report.

Create a Custom Dimension for Content Groups

You can also turn the content_group parameter into a custom dimension in GA4.

<div class="post-action">Go to Admin and click Custom definitions in the Properties column.</div>

custom definitions in GA4

<div class="post-action">Click Create custom dimensions.</div>

  • Enter a name for the dimension. Hyphens aren’t allowed, but it can have spaces or underscores.
  • Choose a scope: event, user, or item. For our example we’ll use event, but you can learn more about scopes here.
  • Enter a description (optional).
  • Select an event parameter or user property (the options change based on what you chose as the scope). This value must match the parameter you entered in GTM.
  • Click Save.

content group custom dimension in GA4

Now you have to wait up to 48 hours for the custom dimension to be active in GA4 - you’ll see (not set) as the value until it’s ready.

You can use custom dimensions in Explorations and make reporting cards for them in the standard reports. In this example it’s an event parameter, so the data can be found under Reports > Engagement > Events. Learn more about conversion event reporting in GA4.

Benefits of Content Grouping

Grouping your content lets you view metrics by content group in your GA4 reports and explorations. Aggregate metrics can help you quickly understand how specific sections of your website are performing. Content grouping is especially helpful for large websites where reporting on individual page performance isn’t meaningful or realistic.

Analyzing page performance by group can help answer questions like:

  • What are my best & worst product categories in terms of online visibility and/or sales?
  • Are product pages or service pages more popular with site visitors?
  • Which blog topics are getting the most pageviews and/or entrances from organic search?
  • Does the most-viewed content on our site correspond to sales?
  • Is content written by author A getting more engagement than content written by Author B? 

Content groups can also be used in custom content drilldown explorations in GA4.

<div class="post-note-cute">If you need help with GA4 implementation, reporting audits, dashboard configuration, or if you have questions about anything analytics related, don't hesitate to reach out: <a href="mailto:info@momenticmarketing.com">info@momenticmarketing.com</a></div>

Resources used to create this article:

https://support.google.com/analytics/answer/11523339?hl=en

https://support.google.com/analytics/answer/1034324

https://support.google.com/analytics/answer/10075209?hl=en

Bar chart showing increase over time with Momentic logo

About the author(s)