Remove Dynamic IDs from Page URLs – Google Analytics Filters

A lot of times your URL contains dynamic ids such as userid, trasaction id etc. in the page URL. They are not appended in the query string but in the page path .  Those URLs , if tracked as is in Google Analytics, will not give you a clear picture of the pages performance as each of the page will show up as a unique page.


A user goes to make a bill payment on your site, the bill payment page is However when user receives the email to make payment, the URL is{user id} , where {user id} is replaced with the actual user id of the user, so it will be a unqiue id for each user. Hence in your Google Analytics you will end up with URL's like

http://www., http://www., http://www. etc.  You get the idea.

As a result pages report in Google Analytics show all these pages with one user. Ideally you would want to consolidate all these pages as http://www. and show actual user count to those pages.  If you want to capture the {user-id} you can capture them in custom dimensions (more on that in another post).

Google Analytics Filters to the rescue

Google Analytics view filters are a powerful way to format the data in the way you want it to show up in your reports. You can apply a filter to a Google Analytics view by going to Admin-->Account-->Property-->View-->Filter


In Filter, create a new filter with following settings:

  • Filter Name: Remove Dynamic IDs from Page URL
  • Filter Type: Custom > Advanced
  • Field A: Request URI
  • Extract A: ^(/bill-payment/)(.*)
  • Field B: (leave it blank)
  • Extract B: (leave it blank)
  • Output To: Request URI
  • Constructor: $A1
  • Field A Required: Select
  • Field B Required: Do not select
  • Override Output Field: Select
  • Case Sensitive: Do not select

Explaining the filter:

^ means that the it is the beginning part of the URI and first part of URI is (/bill-payment/) followed by anything else. It splits the URI in to various parts and these parts are based on where you places the parenthesis (). In this example example /bill-payment/ is captured in part 1 of Field A and hence can be referenced as $A1 and the anything after that is captured in part 2 and hence can be reference as $A2, if required.

Once the URL is extracted and split we then output it in URI (means rewrite the URI) value with part captured in A1, i.e. bill-payment.

Applying Filter

Make sure to first test your filters on a Test View. If that works as expected then apply it to your live view (production view).

Interested in learning more? Check out our course on Optizent Academy.

Leave a Reply

Your email address will not be published. Required fields are marked *