Rewriting URLs Using Advanced Filters in Google Analytics

Rewriting URLs Using Advanced Filters in Google Analytics

Commenting on our earlier post about rewriting URLs using Search & Replace in Google Analytics, Alexander asked

We changed our URL structure from /product/ to category/product. My target is to analyze i.e landingpages & visits. Therefore I need to tell GA that I would like to match the former URL structure to the new structure. Would this then look like the following: search string /product/$ to ^/category/

We replied to the question about how a Search and Replace filter could be used. However, instead of Search and Replace, an Advanced Filter may be less time intensive if Alexander has many products and categories.

Let’s say the Old and New URL structures are:

/product1 /category1/product1
/product2 /category1/product2
/product3 /category5/product3

… then an advanced filter would be a better choice than search and replace because the contents of the fields vary.

Since old Google Analytics can’t be rewritten, only future URLs can be rewritten, and only when the data is collected.  What we’re want to do is eliminate part of the URL, the “/category”.

  • Since we are not combining URLs, we only need to use Field A.  Field B is not required.
  • The round brackets “(” and “)” group the data between the slashes into A1 and A2.
  • Group A2 is the desired data and is the Output $A2 that overwrites the Request URI field.

Rewriting URLs using Advanced Filters in Google Analytics

Important:  Remember to create a new profile and test your advanced filter there first.  If a mistake is made, the data will be permanently affected.  Once you’re sure it works, apply the filter to the main profile.

For more, read Google’s article on Advanced Filters.

By |2014-11-19T09:40:41-05:00February 18th, 2013|4 Comments
Categories: Google Analytics


  1. Francesco December 3, 2013 at 12:24 pm - Reply

    HI, i have a question. I have read this post and the other ( but i won’t make a mistake.
    If i’m doing a new web site with a different url structure (on the same domain) and even a different contents and i use advanced filter, i obtain a continuity in the data?
    Can i see the old page “/category/product” and the new page “different_category/different _product_name” how the same in the storic view?
    Thank you : )

    • June Li December 4, 2013 at 11:01 am - Reply

      Hi Francesco,
      Unfortunately, you can’t rewrite history.

      Two suggestions, neither simple:
      (1) Copy your existing View to a NEW View, and in that new View, rewrite current to the historical URL, if there is a simple, straightforward rule.

      Then compare traffic in your NEW View to historical traffic in your current View.

      Open two browser windows.

      Have the current View (date range before re-design) in one and New View in the other (date range after re-design)

      (2) Download to Excel, do a lookup of old and new page name, and then compare there.

      In the future, consider using a custom dimension in Universal Analytics to consistently define the page. Then instead of URI, use the custom dimension, which can stay constant if you change your URLs again.

      Hope this helps, and thanks for reading our blog,


  2. Lisa July 27, 2018 at 12:48 pm - Reply

    Hi! I have a question. What would my advanced filter look like to help with this scenario?

    We have organic click/impression data being tracked in the Search Console Landing Page report with /index.aspx at the end of each URL from our blog, but the sessions resulting from this do not contain /index.aspx at the end (nor do the actual URLs themselves).

    We want to remove /index.aspx so the clicks are married with their resulting sessions; however, we can’t just strip out /index.aspx since that’s used on some other pages.

    We want to take every blog post URL and remove /index.aspx from the end. All blog post URLs look like this: – (and then the ones in GA are coming in as

    • June Li July 31, 2018 at 2:35 pm - Reply

      Hi Lisa,
      You likely don’t need an Advanced Filter to fix this.

      If the urls shown in GA contain “/index.aspx” even though the actual URLs don’t show this, it’s because sometime in the past, someone set the “Default Page” in your Views’ settings to “/index.aspx”.

      To fix this, someone with “Edit” access now needs to go to Admin > View Settings and remove the contents of the “Default Page” field.

      This won’t fix your history but things will be cleaned up going forward. You’ll be able to tell immediately using Real-Time Content report if this fix works.

      If you have more than one View, you’ll need to do this in every View.

      For more info about the “Default Page” field, read this Google help doc.

      Please let us know if this suggestion works for you.


Leave A Comment