Jump to content

Understanding too high number of clicks


checkad

Recommended Posts

Hello,

Migrating from PhpAdsNew toRevive, I did notice a BIG increase in clicks : 5 times nearly !

Same banners, same campaigns, same number of impressions for the same banners, but the clicks has been multiplied by 5.

I've read all replies saying it was bots in such cases, but not understanding why Revive is more sensible with bots compared to PhpAdsNew.

But to track bots, it did some hack. Here is the code; if it can help anybody to check which bots are making crazy numbers. Note : the code can be enhanced of course.

STEP1

- CREATE 2 TABLES in the same db

CREATE TABLE IF NOT EXISTS `pub_log_bots` (
  `bot` varchar(14) collate utf8_bin NOT NULL,
  `detail` varchar(200) collate utf8_bin NOT NULL,
  `tot` smallint(6) unsigned NOT NULL,
  `lastupdate` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  PRIMARY KEY  (`detail`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

CREATE TABLE IF NOT EXISTS `pub_tmp` (
  `logdate` datetime NOT NULL,
  `clicks` smallint(6) NOT NULL,
  `adid` tinyint(3) unsigned NOT NULL,
  `bot` tinyint(3) unsigned NOT NULL,
  `ip` varchar(16) collate utf8_bin NOT NULL,
  `dns` varchar(100) collate utf8_bin NOT NULL,
  `ref` varchar(200) collate utf8_bin NOT NULL,
  PRIMARY KEY  (`logdate`,`adid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

STEP2

hack the code of the ck.php file (but save the ck.php file first).

go to the line of the MAX_Delivery_log_logAdClick() function. it should be 2146 for the latest release 3.2.4.

then i create 3 arrays to check against user_agent of the browser (good bots have 'bot' in their signature), ips and hosts.

FINAL CODE

I then log in one table, the clicks done by different bots and in the other table, the non-bots clicks (I can then iterate to find other bots or repeating ip address and check them against blacklist in spamhaus)

Final code is here (connection to the db must be changed with your credentials; using the credentials of revive would be better if somebody want to add the correct line for doing it).

function MAX_Delivery_log_logAdClick($adId, $zoneId)
{
if (empty($GLOBALS['_MAX']['CONF']['logging']['adClicks'])) { return true; }

$date=date("Y-m-d H:i:s",time());
$bots= array('mediatoolkitbot','trendiction','google','slurp','crawler','bot','http');
$ips= array('217.113.43.215','195.81.226.146');
$hosts= array('pressrelations.de');

$bot=0;
foreach($bots as $botid) { if (stripos($_SERVER["HTTP_USER_AGENT"],$botid)) {
    $bot=1;break;}
}
if ($bot==0) {foreach($hosts as $botid) { if (stripos(gethostbyaddr($_SERVER['REMOTE_ADDR']),$botid)) {
        $bot=1;break;}
    }
}
if ($bot==0) {foreach($ips as $botid) { if (stripos($_SERVER['REMOTE_ADDR'],$botid)) {
        $bot=1;break;
        }
    }
}

if ($bot==1) {
    $query = "INSERT INTO pub_log_bots (bot,tot,detail) VALUES ('$botid','1','".$_SERVER["HTTP_USER_AGENT"]."') ON DUPLICATE KEY UPDATE tot=tot+1";
    } else {
    $query = "INSERT INTO pub_tmp (logdate,adid,clicks,bot,ip,dns,ref) VALUES ('$date','$adId',1,'$bot','".$_SERVER['REMOTE_ADDR']."','".gethostbyaddr($_SERVER['REMOTE_ADDR'])."','".$_SERVER["HTTP_USER_AGENT"]."') ";
    OX_Delivery_Common_hook('logClick', array($adId, $zoneId, _viewersHostOkayToLog($adId, $zoneId)));
}
$dbc =     @mysqli_connect ('localhost', 'user', 'password', 'dbname');
$result= mysqli_query($dbc,$query);
}

of course, when you have checked which bots, you can go back to the original version of the ck.php file AND use the built in functionnality in the admin to exclude ips, agents

on that page /revivedirectory/www/admin/account-settings-banner-logging.php

Regards,

Link to comment
Share on other sites

  • 4 weeks later...

After 3 weeks, I did authenticate 22 different bots and crawlers and the number is not changing anymore now.

Note that some of tem do say that they are bot or crawler (most of them) but sometimes it's only an IP with no info. So the only way to check is to find that one ips is making a large number of clicks.

Once found, I disable the call to the db but keep the filter on bots and ips and now, figures and numbers are fine and logical.

Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...

if most of bots and crawler are identifying themselves as crawlers or bots, some of them are not.

then you have only one IP that is generating sometimes thousands of clicks by itself.

these are 2 IPs that were massively clicking everywhere.

 

using the code above, i can add either a specific bot not listed as a bot (like xenu recently) or a specific ip that is definitely not human.

i'm thinking about creating a plugin to do this, but I'm missing some infos, especially as i'm hacking the code (definitely not a good way)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...