Skip to content

How to create and track Content Groups in GA4 using Google Tag Manager (2024 – Using the Google Tag)

Content grouping is one of the features you should definitely use when your website gets bigger :

It gives you the ability to group your pages (duh!) so that you can tell if such or such type of landing pages bring more money, more visits, etc…

While you can hardcode it page by page, you can also do this using Regular Expressions (RegEx) in Google Tag Manager.

It is a bit technical, but way more practical if you don’t have access to the actual code of your pages OR you want to do this en masse.

However, Google (and all the other sites that teach you how to do this) has forgotten to update the method since they have upated the Google Analytics Tag to Google Tag.

Here is the step by step guide that works as of November 2023:

Prerequisites :

  • A working Google Analytics 4 property
  • Google Tag Manager
  • Regex101 (for testing our regular expressions)

Step 1: Create your Google Tag Manager Variable

For our purposes, we’ll assume you have a website with urls that look like this :

/products/hat
/products/belts
/blog/trendy-hats

From this we might want to create 2 content groups : one for products and one for blogs

  • First we’ll first head to Google Tag ManagerVariablesNew
  • Change the name of the variable to Content Group
  • Click Variable Configuration and select Regex Table
  • In the Input Variable field, select {{Page Path}}.
  • Add a row to the RegEx Table section. Enter a regular expression to identify page path. In our case, it’ll be :
PatternOutput
/productProducts Page
/blogBlog Page
  • You can check your urls on https://regex101.com/ to see if the filtering would work as intending
  • Select Set Default Values.
  • Enter « Other group » as the default content group if nothing matches.
  • In Advanced Settings, clear the Full Matches Only and Enable Capture Groups and Replace functionality checkboxes.
  • Save your changes.

Voilà, your variable is created.

Step 2 : Update the Google Tag

In your Google Tag Configuration Settings, check that you’ll need to create the following 2 paramters (the first one might already be there

Configuration ParameterValue
send_page_viewtrue
content_group{{content_group}}

Save the changes, and publish your workspace.

Step 3 : find the groups in Google Analytics 4

Wait for 24 hours. In the current version of Google Analytics 4, you’ll find your content groups in, among other things, Pages and Screens (you’ll find these in Engagement)

Hope that helped!

Published inNon classé

Be First to Comment

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *