Rewrite rule not filtering referral spam correctly (anymore)

可紊 提交于 2019-12-07 15:32:53

问题


I've added below rewrite rule to my web.config. It has worked perfectly, blocking all mentioned referral spam sites. However, today suddenly I noticed that social-buttons.com popped up in my Google Analytics. How is this possible with the rule I have defined below?

    <rule name="abort referer spam requests" stopProcessing="true">
      <match url=".*" />
      <conditions>
         <add input="{HTTP_REFERER}" pattern="(semalt\.com)|(buttons\-for\-website\.com)|(simple\-share\-buttons\.com)|(darodar\.com)|(social\-buttons\.com)" />
      </conditions>
      <action type="AbortRequest" />
    </rule>

回答1:


I had the same problem.

social-buttons.com is like darodar.com

they are using your Google Analytics Code to recreate fake information and sending that directly to Google Analytics.

So you cannot do anything with {HTTP_REFERER} to stop it.

The only you can do from (.htaccess) is to block the ip of the visitor who run the script in your site.

But in few minutes he can change his IP and do it again.

(if he enter in your site, more times they just hitting tracking ID UA-000000-01 remotely)

More information you can find in this site.

A smart technique to test your refferal blacklist in htaccess is to install a blackhole trap to your website and in your (.htaccess) to put the following:

RewriteCond %{HTTP_REFERER} social-buttons\.com [NC,OR]
RewriteCond %{HTTP_REFERER} darodar\.com [NC,OR]
//all other refferals you have..

RewriteCond %{HTTP_USER_AGENT} ^libwww-perl [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^libwwwperl [NC]
//all other bad user agents you have..
RewriteRule ^(.*) http://your website/_path_to/blacktrap.php 
// and send them to your trap`

So you will be informed for all the bad refferals or bad agents you will catch.

Also you can use the following technique:

(phpbook.net/how-to-log-ip-adresses-in-php.html)

to log all the ip's that enter to you site.

So to understand where is the problem.

But you will not find refferal from (social-buttons).

Use your google analytics settings to stop it:

METHOD-1

through filters

Step 1 Open Google Analytics | —–> Go to Admin tab | —–> View column | —–> View settings | —–> Bot Filtering

check the box Exclude all hits from known bots and spiders

| —–> View column | —–> Filters | —–> NEW FILTER | —–>

filter name: (the name of your filter)

filter type: custom / exclude

filter field: campaign source

filter Pattern: like the following example

.*semalt\.com|.*kambasoft\.com|.*smailik\.org|.*buttons-for-website\.com|.*o-o-6-o-o\.com|.*makemoneyonline\.com|.*s.aliexpress\.com

and click save

Step 2 create a new view segment to filter out unwanted spam referrals more info: (http://www.analyticsedge.com/2015/01/advanced-segment-eliminate-spam-referrals/)

you can use the following template https://www.google.com/analytics/web/template?uid=hKkT2kdWQpG00jQxbT6p8Q

and chage it to your needs

METHOD-2

Open Google Analytics | —–> Go to Admin tab | —–> Property column | —–> Tracking Info | —–> Referral Exclusion List. | —–>Add Referral Exclusion

(use the following format to add the domains):

*.social-buttons.com

*.semalt.com

etc.

(Return to Admin Tab)

—–> Admin tab | —–> View column | —–> View settings | —–> Bot Filtering

check the box Exclude all hits from known bots and spiders

These settings only work with the analytics.js version of the tracking code. Go to your website and check if you are using the latest code.

It should be the same with:

—–> Admin tab | —–> Property column | —–> Tracking Info | —–> Tracking code

If it is not replace it to each page of your site

METHOD-3

If you’re using the ga.js version and dont want to change your google analytics code you have to follow this method

Step1.

—–> Admin tab | —–> View column | —–> View settings | —–> Bot Filtering

check the box Exclude all hits from known bots and spiders

And configure these settings in your code.

Step2.

Add the following script in website Header, before closing head tag:

<script type=’text/javascript’>
var blocklink = ['http://darodar.com', 'http://social-buttons.com'];
for (var b = blocklink.length; b–;) {
if (document.referrer.match(blocklink[b]))
window.location = “http://google.com/”;
} 
</script>

Or for PHP website add the following code in header.php file of theme folder:

<?php
echo”<script language=’javascript’>
var blocklink = ['http://darodar.com', 'http://social-buttons.com'];
for (var b = blocklink.length; b–;) {
if (document.referrer.match(blocklink[b]))
window.location = “http://google.com/”;
} 
</script>
“;
?>


来源:https://stackoverflow.com/questions/29232903/rewrite-rule-not-filtering-referral-spam-correctly-anymore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!