unable to block referrer spam

610 Views Asked by At

I am trying to block referrer spam on client and server side:

client side:

<script type='text/javascript'>
var unforgivable = ["darodar.com", "econom.co", "ilovevitaly.co"];
var re = new RegExp(unforgivable.join("|"), "i");
if (document.referrer.match(re))
    window.location = "http://google.com/";
</script>

server site, via a servlet filter:

static String[] unforgivable = new String[]{"darodar.com", "econom.co", "lovevitaly"};
for (String badUrl: unforgivable)
    if(requestURI.contains(badUrl)) {
        res.setContentType("text/html");  
        PrintWriter pw=res.getWriter();  
        response.sendRedirect("http://www.google.com");
        pw.close();     
    }

However, I keep getting ilovevitaly.co and darodar referrers when looking to my google analytics. Any clue?

5

There are 5 best solutions below

1
On

try using the .htaccess to stop spamming, a template can be found here: http://www.sebastianviereck.de/en/template-referer-spamm-htaccess-to-remove-from-google-analytics/

1
On

Google Analytics fires at the request, which comes before your request handlers. So yes, they will show up.

You might try blacklisting the IP addresses : https://cloud.google.com/appengine/docs/java/config/dos

That will fire before your request handlers, and before Google Analytics.

0
On

Due to several searches on the internet and several tests on the website I manage, this is a resume that I've read : There are 2 bots/referral spammers kind : - a ) those who crawl your web like semalt. Have a look to your traffics logs supply by your hosting provider to identify them. - b ) the other, which have only cracked your Google analytics ID to generate false traffic to include in your google stats. Their never visit your site. (darodar.com", "econom.co", "ilovevitaly.co belongs to this family)

Members of the A category can be blocked trough Htacess rules Members of B must be filtering by a filter in GA.

More across the link

Happy new Year - Meilleurs voeux

Nota : This text does not translate by Google. I Beg your pardon, my English isn't fluent.

0
On

Filter future and historical ga spam of all types with the link provided. Hostname filtering is particularly easy.

https://www.ohow.co/ultimate-guide-to-removing-irrelevant-traffic-in-google-analytics/

The only valid hostname is that of your websites (sub)domains. The author of the guide has created, and maintains, the regex to exclude all types of ga spam.

This makes GA usable again :-)

0
On

The only option is to try to hide your Google Analytics ID before spammers bot parsed your website homepage. This can be done by manipulating with Analytics JS code like this:

ga('create', 'UA-XX' + 'XXXX' + 'XX-X', 'auto');