I am using the following regex to exclude spam sites:


When I added a Segment with this filter, I get the desired results. However, when I created a View with a Filter, it didn't filter buy-cheap-online.info. I suspect that as the days go on, it will not filter the other sites. (I understand that Filters are not applied retroactively.)

Why doesn't the same regex work in both Segments and Filters?

  • 3
    FYI you don't need to backslash escape hyphens in a regex (unless they occur in the middle of a character class and you wish to match a literal hyphen.)
    – MrWhite
    May 2, 2015 at 12:14

1 Answer 1


Your expression should work fine on both is strange that it doesn't for filters. I tested here https://regex101.com/

Probably the filter hasn't started working yet. Filters may take up to 24hrs for start showing in your stats https://support.google.com/analytics/answer/6046990?hl=en

GA allows simpler syntax for basic expression, dots and hyphens don't need to be escaped you can write your expression like this


It will work the same and save you some characters

UPDATE: This Expression should be used with Campaign source on the Field type. More information here:


  • Thank you for the additional info. What concerned me was that I click "Verify Filter" to see if any changes would occur after it went into effect, and it said no. I've reapplied the updated filter that you and @w3d recommended and will check back in a couple days. May 2, 2015 at 15:14
  • I've waited a week to collect data with the filter; it does not work. Using social-buttons.com|darodar.com|free-share-buttons.com|buy-cheap-online.info|Get-Free-Traffic-Now.com|hol.es|hulfingtonpost.com|googlsucks.com still lets through site3.free-share-buttons.com and www.Get-Free-Traffic-Now.com. It may let the others in if I give it more time. May 13, 2015 at 5:54
  • Matt are you using Exclude > Campaign Source on the filter field? May 13, 2015 at 7:35
  • I am using Request URI as the filter field. (Screenshot: postimg.org/image/li8q0y3av) May 13, 2015 at 16:45
  • 1
    The Request URI is the part of the URL after the hostname for example somehost.com/some-page, the request URI is /some-page, so that's why your filter is not working. Change it for Campaign Source and it will work, here is more info stackoverflow.com/a/28354319/3197362 May 13, 2015 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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