- Grouping by definition of rules:
This is the simplest option, but at the same time more laborious and manual. It consists of creating rules to assign content. First we will choose the dimension (Name on screen, Page and Title of the page) and then the matching option.
For example: Page> contains> / pants /
- Grouping by extraction: This option will allow us to extract pages through the dimensions Name on screen, Page and Title of the page using a regular expression. It will consist of detecting a common part and a differentiator within our dimensions to form a pattern.
For example: using the Page dimension / men / shirts / / men / pants / / men / shirts / /mens/(.*?)/ (. *?) It is the differentiating part that we are going to extract to classify our content.
Once the variables are created in GTM, the next step will be to associate them with a Google Analytics tag. Within the option of Content Groups, we will put the same index that we put in Google Analytics.
In the previous example, two variables have been created (template and category_name) that will be used as a content group (indexes 1 and 2). With this, the entire Google Tag Manager configuration would already be present. Now, from Google Analytics we can use these groupings of content as primary and secondary dimensions. We can see them in the Behavior / Content / All Pages report as a primary dimension if we display “Content Grouping”. 
- Grouping by tracking code:
This way of grouping the content can be done using Google Tag Manager, in this way we avoid inserting it directly into code. The first thing we will have to do is enable the tracking code in Google Analytics: 
