Google Analytics 4 (GA4) has a great feature called Content Grouping. In a nutshell, it's a way to logically categorize your pages to derive more meaningful insights from your GA data, and ultimately enhance your website and user experience.
An Illustrative Example of Content Grouping
Suppose you have an e-commerce website with various sections - products, categories, checkout, content pages like FAQs, About Us, etc. The Content Grouping feature allows you to combine the data from these various sections, providing a more holistic understanding of user behavior. Similarly, if you're running an educational website, you might want to categorize data under topics, and articles.
Remember, how you categorize depends on your specific needs and the nature of your website therefore it's good to think about your needs before proceeding.
Setting Up Content Grouping: A How-To Guide
Implementing content grouping involves adding a specific code to each page to indicate its content group to GA4. One page belongs to one group. You have two ways to go about this:
-
Directly through Code: Request your developer to add a line of code to your GA tracking code. gtag('set', 'content_group', '<name_of_content_group>'); This added line assigns a particular page to a content group. For instance, you could designate a page as belonging to "men's clothing" or "women's clothing." gtag('set', 'content_group', 'mens');
-
Through Google Tag Manager (GTM): GTM makes the process somewhat easier. There's 2 main steps (tags and variables)
To give you a hands-on feel, we'll share how we did it on the One Scales website with Google Tag Manager. We have articles (much like a blog), with different topics under tags or categories. For us, all articles have special URLs containing the word 'blogs', and categories contain the word 'tagged'.
In GTM, we added a 'Content Group' to the GA4 configuration code. Then, using a user-defined variable, we employed a regex table (a simple coding tool to recognize patterns). Based on the patterns identified in the URL, it categorizes the content group as an 'Article Category' or 'Article'. If the URL has 'pages', it tags them as 'Pages'.
Step 1 - Setup Tag
Step 2 - Setup Variable
Important URL
- GA4 Content Grouping - https://support.google.com/analytics/answer/11523339?hl=en#zippy=%2Cgoogle-tag-manager-websites%2Cgoogle-tag-websites