1

I am using the following regex to exclude spam sites:

(social\-buttons\.com|darodar\.com|free\-share\-buttons\.com|buy\-cheap\-online\.info|Get\-Free\-Traffic\-Now\.com|hol\.es|hulfingtonpost\.com|googlsucks\.com)

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 '15 at 12:14
2

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

social-buttons.com|darodar.com|free-share-buttons.com|buy-cheap-online.info|Get-Free-Traffic-Now.com|hol.es|hulfingtonpost.com|googlsucks.com

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:

https://stackoverflow.com/a/28354319/3197362

  • 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. – Matt Norris May 2 '15 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. – Matt Norris May 13 '15 at 5:54
  • Matt are you using Exclude > Campaign Source on the filter field? – Carlos Escalera Alonso May 13 '15 at 7:35
  • I am using Request URI as the filter field. (Screenshot: postimg.org/image/li8q0y3av) – Matt Norris May 13 '15 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 – Carlos Escalera Alonso May 13 '15 at 16:53

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.