: Combine trailing slashes in analytics Inside my analytics profile, I have to aggregate data from URLs when they are on separate rows because example.com/path is different from example.com/path/.
Inside my analytics profile, I have to aggregate data from URLs when they are on separate rows because example.com/path is different from example.com/path/. This is a huge usability headache, so I figured there would be many solutions to this issue already. I followed what this guy did here and created a filter to rename the URI.
He creates a regex ^(/[a-z0-9/_-]*[^/])$ that matches alphanumeric, underscore, and dash characters and doesn't match those that end with a slash. The URI is output as the same value with a slash, assuming it matches the regex. I have tried both this regex, and the same regex with the slashes escaped ^(/[a-z0-9/_-]*[^/])$ as this online regex tester instructed me to do, but my reports are not updating with the new filter.
When I send traffic to example.com/path and example.com/path/ with the new filter saved, it is still showing up as two records.
Did I miss a step?
edit
I've also tried (^/.*?)/+$
This is my appening a slash regex
This is my other filter to show full domain
More posts by @Hamaas447
2 Comments
Sorted by latest first Latest Oldest Best
After attempting what lunametrics did to combine their URIs with & without ending slashes, and not getting it to work, I started to think about the problem in a different way. Instead of appending slashes when they are missing, why not remove them if they are there? i.e. example.com/path/ would then become example.com/path in my reports.
Note: This is probably only a good idea if you also have the other URI rewriting filter I use, that adds the hostname to your reports. Otherwise views to your index page, which would normally be reported as / would probably show as a blank line. I'm not actually sure what would happen... But this is a solution for me that answers my problem: how to combine related rows in my reports.
Here is my filter that I have working ($ denotes the end of the string and the preceding / is a single character match which then gets 'replaced' with nothing):
Perhaps try simplifying your filter to something like this:
So something like /test1/test2////// becomes /test1/test2/, or /test becomes /test/.
Note that you don't need to escape / slashes as GA uses a different regex engine than what people normally use.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.