Cleanup your URLs with Search and Replace Filters

If your site has dynamic URLs then you might have a hard time making sense out of your data in Google Analytics.

If for any reason you cannot convert your dynamic URLs to friendly URLs…search and replace filters are the answer!

The screenshot below demonstrates the nightmare some people might experience when they view content reports.

In order to make the URL readable, we have to identfy the parameters that we want to change. In our above example the URL contains three parameters: departmentID, CategoryID, and ProductID. We first create a “search and replace” filter for each department, category, and product. Then we replace each dynamic parameter with easy-to-read text.

  • Create the “Search & Replace” Filters

Filter# 1

Filter# 2

Filter# 3

  • Now apply all created filters to a test profile and verify data accuracy before applying to your regular profiles.

Your content reports will now look like this:


  • We do not advice using “Search & Replace” approach on e-commerce sites because you will have a very large number of filters.
  • The easiest way to never have to deal with dynamic URL addresses is by using friendly URLs at the development stage.
  • You can use tools such as Apache’s mod_rewrite to present clean URLs to both your visitors and your web analytics application.
  • Clean URLs will have additional benefits such as helping with your SEO campaign and improving conversion rates..

12 thoughts on “Cleanup your URLs with Search and Replace Filters”

  1. Nice post. So if the filter string represents only a portion of the URI, will GA only replace that segment of the URI or replace the whole URI given there are no other filters?

  2. Hi Alan,

    You are absolutely right. The search field is a regular expression and the replace field is any text that you wish to use to replace the original text.

    The screenshot is updated now.

    Thank you,

  3. What would happen to the utm codes if you search and replace them?

    Say I have a default.aspx page and I also have hundreds of entries like default.aspx?utm_campaign=blah etc etc.

    Will the tracking still display in the reports for those campaigns.

    In other words is it logged before of after the URI string re-write?

  4. Hi Antonio,

    Google UTMs [utm_source, utm_medium,…] should not be added to your sites’ pages. UTMs are used for external tagging.

    If you have a link to your site from an email campaign and that link has all UTMs attached to it, Google Analytics will not report these utms regardless if you have the above search/replace filters applied or not.

  5. Thank you for this. Is the Search & Replace filter supposed to actually replace the existing data or just start displaying the updated URL from the day the filter is put in place? Mine is displaying the new URL instead of replacing the old one, so now I have data in two places.

  6. Hello Sir,

    One of my client ecommerce site have dynamic URLs. Wanted to know how to replace that. Appreciate if you can guide whether I’m doing it right or wrong.

    Main Category – /Products/ProductList.aspx?103=57
    I changed it to – ^/Products/ProductList\.aspx\?103=57.*
    I done that through the post here
    Please let me know if I’m doing it right or wrong. Also, please guide me on how to do it for sub-category & product detail pages.

    Product Detail Page URL – /Products/ProductDetail.aspx?productid=61962

    Thanks a lot sir for this awesome post.

  7. Helo Sir,
    I used search and replace filters for campaign tagging.
    My site is tracked by two analytics tools, but I used only NI tracking parameters for external traffic. Now I’m using Search & Replace filters to replace Netinsight parameters with utm params, goal is to see traffic attribued to the campaigns data.

    It appears the search and replace filters for campaign tagging are working and correctly replacing the NI arguments, but the traffic is still showing up in GA as direct, and GA is not stripping off the arguments or correctly attributing the source of the traffic. Do you have any idea why this might be the case?

    Thanks in Advance

Leave a Reply

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


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">