Grouping Pages in Google Analytics

IMPORTANT:

This is a historical post from 11 January 2010.

Question: How can I group pages together for reporting within Google Analytics?

In this post we will look at how we can use; Advanced Table Filters, Profile Filters and Multiple Custom Variables to group pages together for reporting within Google Analytics.

google-analytics-group-content

google-analytics-group-content

We are going to use an online toy shop as an example for this post. Let's say the website has toys in the following categories:

  • Bicycles
  • Dolls
  • Games
  • Learning

Basic: Content Drilldown

If the site already has a logical folder structure then there are very simple ways to group content.

Firstly, browse your website and look at the URLs for the individual pages you want to group.

If you see URLs such as the following:

  • www.toys.com/bicycles/
  • www.toys.com/bicycles/bmx-bikes
  • www.toys.com/bicycles/product.php?id=3012

Where all the pages you want to group have a common element in the URL (in the example above you can see /bicycles/ is in all the URLs we want to group), then you can navigate to Content > Content Drilldown to see all the pages rolled-up into /bicycles/.

If you have pages that don't have a common element in the URL then you will have to be a little more advanced!

Intermediate: Advanced Table Filters and Profile Filters

If you see URLs such as the following:

  • www.toys.com/product/index.php?id=3829 for a boys bicycle
  • www.toys.com/product/index.php?id=1258 for a teens bicycle
  • www.toys.com/product/index.php?id=7248 for a doll
  • www.toys.com/product/index.php?id=3457 for a preschool board game
  • www.toys.com/product/index.php?id=1263 for a brain game

And you only want to group the boys bicycles and teens bicycles, then you have two options.

Firstly, you can navigate to Content > Top Content within Google Analytics and then apply an Advanced Table Filter that only matches those two pages.

advanced-table-filter-001

advanced-table-filter-001

Click 'Advanced Filter' and enter 3029|1258 (this will match 3029 OR 1258 within the report using | which is the pipe symbol):

advanced-table-filter-002

advanced-table-filter-002

Once you click 'Apply Filter' the Top Content report will only include data for the two bicycle pages. You will have to add the ID numbers for any other pages you want to include in the report (e.g. 3029|1258|9620|3892 etc.)

Once you have done this you you can consider setting up a filtered profile that will only report on the pages you have identified. Create a new profile and apply a filter like the following:

profile-filter

profile-filter

The above is an include filter with the following as the filter pattern: ^/product/index.php?id=(3829|1258) this will match /product/indexphp?id=3829 AND /product/indexphp?id=1258.

Advanced: Multiple Custom Variables

Advanced Table Filters and Profile Filters are fantastic but if you change your site you also have to update your filters which could be a pain. You might also have a LOT of pages, and filters might be restrictive and take a lot of time to setup. If you fall into this area then Multiple Custom Variables are going to be the best solution.

Multiple Custom Variables are going to be more involved to setup because they need to be placed within your site's code but with the help of yourweb developer or IT support it shouldn't be too hard to get it setup correctly.

Once you have defined which pages should be grouped (e.g. all the bicycle pages) then you will need to dynamically create Multiple Custom Variables within the code of your pages.

So for all the bicycle pages you will need the following to be within your tracking code:

pageTracker._setCustomVar( 1, // Multiple Custom Variable is set to slot 1 "Product Section", // Overarching name (or category) "Bicycles", // This value of the custom variable 3 // Sets the scope to pageview-level );

Then for your games pages you might need:

pageTracker._setCustomVar( 1, // Multiple Custom Variable is set to slot 1 "Product Section", // Overarching name (or category) "Games", // This value of the custom variable 3 // Sets the scope to pageview-level );

And so on for each section you want to track. Once your pages are dynamically tracking into the Multiple Custom Variables, you will be able to access the Custom Variables report within Google Analytics.