This method is called ‘Group by Tracking Code’ in Google Analytics.
You can see this method while creating/editing ‘Content grouping’ (Admin >’ View’ column > Content Grouping):
Use the ‘Group by Tracking code’ method for creating content groups:
#1 If you are comfortable making code changes on your website and you understand the Google Analytics development environment and/or if you know/hire someone who does.
#2 You want to create very robust content groups that can withstand any change made to the URLs and/or title tags of the web pages which are part of the content groups.
#3 If you have got web pages whose titles or URLs are too hard or impossible to capture via regular expression (‘group using extraction’ method) or rule sets (‘group using rule definitions’ methods).
#4 If you want to make sure that the same web page is not included in multiple content groups.
The ‘Group by Tracking Code’ is my favourite method for creating content groups in Google Analytics because it is very robust.
But this is not the case. Google is confusing you here. So beware.
In order to see the index number of a content grouping, navigate to the ‘Admin’ section of that GA view for which you created ‘content groupings’ and then click on ‘Content Grouping’ link:
You can now see the index number assigned to each ‘content grouping’:
Now, if you want to create a new ‘content grouping’ then do not use the index number which is already in use. Otherwise, your web pages may be assigned to the new content grouping.
These index numbers act as slots and you can put only one content grouping at a time to these slots.
Making a call to an index number
If you want to refer to a ‘content grouping’ within your code then you would need to make a call to its index number.
For example, if the name of your content grouping is ‘Men Clothing’ then first identify its index number and then make a call to this index number, from within your code.
You can make a call to an index number by using the Google Analytics command called ‘set’ before sending a pageview hit.
This command is also used to create new content groups.
Following is the syntax of the ‘set’ command for creating a new content group within the content grouping (specified by its index number):
This line of code is added to the Google Analytics tracking code, of all those web pages, which will be part of the new content group:
<!– Global site tag (gtag.js) – Google Analytics –> <script async src=”https://www.googletagmanager.com/gtag/js?id=UA-1123456-78″></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag(‘js’, new Date()); gtag(‘config’, ‘UA-1123456-78’, {‘content_group<Index Number>’: ‘<Group Name>’}); </script>
For example, let us suppose, you want to group all the web pages on your website, which sell men’s shirts into the content group named ‘Men Shirts’
Let us also suppose, that the index number of your content group is 1.
Now in order to create this content group, you would need to make following similar changes, to the Google Analytics tracking code, of all those web pages, which will be part of the new content group named ‘Men Shirts’:
<!– Global site tag (gtag.js) – Google Analytics –> <script async src=”https://www.googletagmanager.com/gtag/js?id=UA-1123456-78″></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag(‘js’, new Date()); gtag(‘config’, ‘UA-1123456-78’, {‘content_group1’: ‘Men Shirts‘}); </script>
Note: Do not call the same index number multiple times on the same web page, like the one below:
<!– Global site tag (gtag.js) – Google Analytics –> <script async src=”https://www.googletagmanager.com/gtag/js?id=UA-1123456-78″></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag(‘js’, new Date()); gtag(‘config’, ‘UA-1123456-78’, {‘content_group1’: ‘Men Shirts‘, ‘content_group1’: ‘Men Trousers‘}); </script>
If you call the same index number multiple times on the same web page then only the last call for the index number will be sent to GA, along with the pageview.
In our case the last call would be:
gtag(‘set’, {‘content_group1’: ‘Men Trousers‘});
So the web page where you put this code will belong to the ‘Men Trousers’ content group and not to ‘Men Shirts’ content group.
Remember when you use the ‘Group by Tracking Code’ method, you can assign only one ‘content group’ at a time to a web page.
Note:
<!– Global site tag (gtag.js) – Google Analytics –> <script async src=”https://www.googletagmanager.com/gtag/js?id=UA-1123456-78″></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag(‘js’, new Date());
<!– Global site tag (gtag.js) – Google Analytics –> <script async src=”https://www.googletagmanager.com/gtag/js?id=UA-1123456-78″></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag(‘js’, new Date()); gtag(‘config’, ‘UA-1123456-78’, {‘content_group1’: ‘Men Trousers‘}); </script>
You can use either ‘set’ command or ‘config’ command to set up content group in GA.
Get my best selling books on Attribution Modelling
Learn to implement attribution modelling in your organisation
Understand the customer purchase journey across devices
Determine the most effective marketing channels for investment
Click book covers to find out more
Steps to create content groups in GA via the ‘Group by Tracking Code’ method
Follow the steps below to create content grouping and corresponding content groups in GA via the ‘Group by Tracking Code’ method:
Step-1: Decide the names and number of content/product categories which you will use as ‘content grouping’ in your GA reporting view.
Step-2: Decide the names and number of content/product sub-categories which you will use as ‘content groups’ in GA for each ‘content grouping’.
Step-3: Identify all of the web pages which will be part of each ‘content group’.
Step-4: Navigate to the ‘Admin’ section of your GA view and then click on ‘Content Grouping’ link:
Step-5: Click on ‘New Content Grouping’ button:
Step-6: Name your content grouping and then click on the ‘Enable Tracking Code’ link as shown below:
Step-7: Select the index number for your new content grouping from the ‘Select Index’ drop-down menu:
Note: Do not use the index number which is already in use.
Step-8: Modify your Google Analytics tracking code according to the snippet you see and the way I explained earlier:
Step-9: Click on the ‘Done’ button. At this point you can choose to use other methods (‘Group using Extraction’ and ‘Group using rule definitions’) to create more content groups, or you can simply click on the ‘save’ button:
Using different methods for creating content groups for a particular content grouping
You can use any or all of the following three methods at the same time to create different content groups within a content grouping:
‘Group by Tracking Code’
‘Group using Extraction’
‘Group using rule definitions’
However, when you use more than one method at a time, to create content groups, GA executes different methods, in the following order:
#1 ‘Group by Tracking Code’ method is executed first for creating a content group.
#2 ‘Group using Extraction’ method is executed second.
#3 ‘Group using rule definitions’ method is executed last.
Within ‘Group using rule definitions’ method, GA executes various rules from top to bottom:
You can drag the rules up and down to change the order in which they should be executed by GA.
"How to use Digital Analytics to generate floods of new Sales and Customers without spending years figuring everything out on your own."
Here’s what we’re going to cover in this training…
#1 Why digital analytics is the key to online business success.
#2 The number 1 reason why most marketers are not able to scale their advertising and maximize sales.
#3 Why Google and Facebook ads don’t work for most businesses & how to make them work.
#4 Why you won’t get any competitive advantage in the marketplace just by knowing Google Analytics.
#5 The number 1 reason why conversion optimization is not working for your business.
#6 How to advertise on any marketing platform for FREE with an unlimited budget.
#7 How to learn and master digital analytics and conversion optimization in record time.
My best selling books on Digital Analytics and Conversion Optimization
Maths and Stats for Web Analytics and Conversion Optimization
This expert guide will teach you how to leverage the knowledge of maths and statistics in order to accurately interpret data and take actions, which can quickly improve the bottom-line of your online business.
Master the Essentials of Email Marketing Analytics
This book focuses solely on the ‘analytics’ that power your email marketing optimization program and will help you dramatically reduce your cost per acquisition and increase marketing ROI by tracking the performance of the various KPIs and metrics used for email marketing.
Attribution Modelling in Google Analytics and BeyondSECOND EDITION OUT NOW!
Attribution modelling is the process of determining the most effective marketing channels for investment. This book has been written to help you implement attribution modelling. It will teach you how to leverage the knowledge of attribution modelling in order to allocate marketing budget and understand buying behaviour.
Attribution Modelling in Google Ads and Facebook
This book has been written to help you implement attribution modelling in Google Ads (Google AdWords) and Facebook. It will teach you, how to leverage the knowledge of attribution modelling in order to understand the customer purchasing journey and determine the most effective marketing channels for investment.
About the Author
Himanshu Sharma
Founder, OptimizeSmart.com
Over 15 years of experience in digital analytics and marketing
Author of four best-selling books on digital analytics and conversion optimization
Nominated for Digital Analytics Association Awards for Excellence
Runs one of the most popular blogs in the world on digital analytics
Consultant to countless small and big businesses over the decade
Learn and Master Google Analytics 4 (GA4) - 126 pages ebook
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of all the cookies.
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
Cookie
Duration
Description
cookielawinfo-checkbox-analytics
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional
11 months
The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy
11 months
The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.