How to extract the plain URL from a URL with query parameters using Google Data Studio

When you have a website, you often have product category pages or search results pages that include parameters. Something like this:

In this example your user searched for the term “lawn widget” and set the maximum price to 500 $/€/etc.

When you have searches for 2,000 different products, it makes it impossible to use your standard Google Analytics data to cleanly compare use of the page overall — eg, the /product-search page.

Here’s how to get just the clean URL in Google Data Studio.

This is handy because it works for all historical data in Google Analytics, whereas if you set up a filter in a new view, that will only apply to pageviews from there on out.

What you’ll need

  1. Google Analytics set up on your website
  2. Access to the Google Analytics account
  3. Create a Google Data Studio report

Steps to extract the page URL without the query parameters

  1. Open your Google Data Studio report if you have one, or create a new one and add the correct Google Analytics account as your source data
  2. In the menu, click “Resource,” then click “Manage Added Data Sources”
  3. For the GA data source you want, click “Edit”
  1. Click “Add a Field”
  1. Name the field “Page URL with parameters removed” (or whatever you prefer)
  2. Copy and paste this formula into the Formula field.
REGEXP_EXTRACT(Page, "^([\w-/\.]+)\??")
  • If you get an error message, manually delete and re-type the quotation marks in the formula.
  • If you still get an error message, re-type with a double backslash in each spot where there is a backslash:
REGEXP_EXTRACT(Page, "^([\\w-/\\.]+)\\??")
  1. Click Save.

  1. Click Done.

You can now create a chart using the new field as a Dimension.

Bonus: To remove the underlining in a chart

  1. Select the chart
  2. Click the link icon next to the dimension name

  1. Change the Type from URL to Text