Tidying up the Pages Viewed reports in Google Analytics

Many companies lose quite a lot of interesting information in their Google Analytics reports by leaving ‘query strings’ in page URLs. You’ll know what I’m referring to if you’ve ever looked at the pages viewed report and you see the same page with multiple entries, each followed by a question mark and various parameters. What you really want is to gather these all up under the same page heading.

Firstly, let’s see if you have this problem. Go to Behaviour > Site Content > All Pages and type a ? in the search box, then click the magnifying glass. This should give you a list of all pages where there are ‘query strings’. Do you see the same page (or pages) multiple times, with different strings? Would you like them all as one entry? If so, read on.

Before we go any further, we may need to cater for a special instance of this, which is the site search. Google Analytics can give you a special report on site searches if you set it up. If you see what are clearly site searches in the page report above, make a note of the query parameter. For example, if the searches are listed as something like:
/?s=something
/?s=whatever

…etc., then the search parameter is s. Go to the Admin section and select the View you want to update, then under ‘View Settings’ there’s a section for ‘Site Search’. Just put s (or whatever) in the Query Parameter field, check the ‘Strip query parameters out of URL’ box and save. The site search report, which will start populating from this point, is under the Behaviour section.

Let’s get back to the parameters you truly want to get rid of. You’ll need to make a note of what they are in the All Pages report above. Let’s say you see:
/?x=something
/?lang=whatever

or even
/?lang=whatever&x=something
…then the parameters are x and/or lang. Go to the Admin section and select the View you want to update, then under ‘View Settings’ there’s a field for ‘Exclude URL Query Parameters’. Just put x or lang or x,lang in the field, and save. From now on, Google Analytics will ignore that part of any page URLs, so if last week you got:
/blog/?x=something 4 views
/blog/?x=whatever 3 views
…next week you’ll probably see something like:
/blog/ 7 views

Need to go further? It’s actually possible to rewrite query strings on the fly to match a specific custom format. For this you need to set up a search and replace filter. It’s not too bad once you get the hang of it.

As with so much, I often set up a ‘Test’ View in Google Analytics to try these things out. Under ‘View Settings’ there’s a ‘Copy View’ button. Do this, make your changes to the new copy view, then come back next week to compare the two and see if your new copy view looks better. If so, you can make the same changes to the original view.