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:
|Old URL||New URL|
… 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.
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.