Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chavesm/d15862c57dd3b782dc9f0f7ad262cf33 to your computer and use it in GitHub Desktop.
Save chavesm/d15862c57dd3b782dc9f0f7ad262cf33 to your computer and use it in GitHub Desktop.
ow to clean up URL search query parameters for Google Analytics reporting

How to clean up URL search query parameters for Google Analytics reporting

These instructions are for Universal Analytics properties.


Here's a screengrab of what we'd like to clean up.

Query parameters in site content report

Our goal is to strip the following query parameter string from our search URLs. At the same time, still recording site search keywords so we know what people are searching for on our site.

/?s=&cat=plus-5-results

Step 1 Create a new view in your GA property

Log into your Google Analytics account and select the Universal Analytics property where you want to clean up the query parameters.

Click on Admin in the lower left of the Home page. Click on Create View in the middle panel.

Name the new View, e.g., My Site No Query Parameters. Make sure the website URL, time zone, and currency are correct.

You can keep the Default page setting blank and the Bot Filtering checked.

Step 2 Check the Exclude URL query parameters field

Make sure s,cat are not in the Exclude URL Query Parameters field. This field is great for cleaning up non site search query parameters such as i, lang, fbclid, page, id, and linklid.

Learn more about this Exclude URL query parameters setting here.

Step 3 Enable site search tracking

Click the slider button to ON under Site Search Settings > Site search Tracking.

Add s in the Query parameter field. We're telling Google that this is the search query parameter for your site. Make sure you use a comma between the two parameters.

Check the box next to Strip query parameters out of URL. This tells to Google to not show this search query parameter in reports and don't count it as a its own pageview stat.

Click the slider button to ON under Site search categories.

If you have a category search and its parameter is cat, add cat in the Category parameter field.

Check the box next to Strip category parameters out of URL.

Your View settings should look like this.

View settings to strip query parameters.

Click Save at the bottom of the page.


Results

No more query parameters in Behavior > Site Content > All Pages.

All Pages Report

But, all search terms are preserved and show up under Behavior > Site Search > Search Terms.

Search Terms Report


Reference

Learn more here.

How to Set Up Site Search Tracking in WordPress (Step by Step) published by MonsterInsights.

Set up Site Search Google Support docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment