2

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 enter image description here

This is my other filter to show full domain enter image description here

  • Hi. Can you screen shot your filter set up in GA? The example from Lunametrics should work. – Kirsty Simms Dec 16 '16 at 11:30
  • Additionally, filters take up to 24 hours before being applied. Are you sure you are waiting the appropriate length of time? – Kirsty Simms Dec 16 '16 at 11:32
  • Can you share a screenshot of your filter? – nyuen Dec 16 '16 at 14:13
  • @KirstySimms please see my edit – smilebomb Dec 16 '16 at 15:31
  • @nyuen please see my edit – smilebomb Dec 16 '16 at 15:31
3

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):

enter image description here

| improve this answer | |
  • I had exactly the same problem. This solution put an end to it. Thanks! – Cansu Aug 16 '17 at 22:43
1

Perhaps try simplifying your filter to something like this:

enter image description here

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.

| improve this answer | |
  • Thanks for helping. This doesn't appear to be working. The way I tested this was going to example.com/path and in a separate browser going to example.com/path/ and viewing the real time section in analytics. It shows up as two separate records. Also, see my edit about my other filter. – smilebomb Dec 16 '16 at 18:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.