Do you ever look at your Google Analytics page report and see that your pageviews report has many items for the same page, and you have to filter to get the “real” total value?
The screenshot above shows that /page-1 has 137K pageviews, but a filtered view (including /page-1 and all variants with the ?infinity= query parameters) have a total of 147K pageviews. There are nearly 600 lines of data for just one page because of this query parameter, and the data becomes difficult to read.
Three kinds of query parameters
Before throwing salt and holy water at any query parameter you see in Google Analytics, ask yourself – why does it exist and does it need to be exorcised?
I’ve noticed there are 3 kinds of query parameters:
- Rubbish query parameters that just pollute the data (e.g. Marketing tags). These allow your analytics software to understand what campaign they are associated with. They (usually) don’t serve a different a different version of the page, and in the URL report should show in one line of data.
- Less rubbish tags that serve a different version of an existing page (e.g. filters). These tags are things like /bedsheets/?colour=1235. Maybe you want to understand if filters were used (in which case you only need to show two pages: /bedsheets/ and /bedsheets/filtered, for example) or you need to get actual data out of this such as what colour corresponds to “1235”.
- Not rubbish query parameters that are different pages every time. Occasionally, entire websites are built on query parameters, and each one has a purpose and is an individual page and that’s fine (maybe).
How do I identify URLs with query parameters in Google Analytics?
To find URLs with query parameters in Google Analytics, go to your pages report (Behaviour>Site Content>All Pages) and filter for \?|\= (Regex saying “any page including = or ?). This will give you a list of pages that contain query parameters.
You can then go through your pages (either manually or using Excel’s text-to-columns) to pick out common ones. A query parameter is the string that comes between “?” and “=”.
Make a list of these parameters, determine what function they have, and decide what needs to be done with them. I use three options:
- Strip from URL
- Rewrite to be more useful
- Leave
This can be determined by the role they play on your website. As a rough guide, if a change in query parameter does not change the content on the page, strip it from the URL. If there is some useful information that’s difficult to read, re-write it. If it’s entirely useful, leave as is.
How to remove query parameters from Google Analytics reports
To remove query parameters, go to Admin>View Settings
Under Exclude Query Parameters, add the list of query parameters you would like to exclude (each separated by a comma). Once entered, click save and annotate your timeline to note the query parameter removal.
Note: If you exclude the query parameter, the pageview is still counted but it is attributed to the page without the query parameter.
How to rewrite URL query parameters in Google Analytics
To rewrite URLs in Google Analytics you can use a search-and-replace filter by going to Admin>Filters and creating a new custom filter.
- Select “Request URI” from the filter field
- Put the \?[query1,quer2]=.* in the search string where query1 and query2 are the ones you want to replace with useful information
- Add whatever text you want to see instead of the query parameter in “Replace String”
Save the filter and annotate your changes.
If you have any questions, feel free to contact us.