Surfing the Internet I came across this blog that posted a PHP code that simulates the Alexa Toolbar for every user that visits your site. The idea behind it is to make Alexa's data on your site more accurate, since it tracks all your actual users and not just the toolbar users.
I'm not sure if it works, since the code is poorly written, but I think that the idea behind it is pretty good.
Here is the code posted by the owner of the blog:
PHP Code:
<?php
function sendPost($host,$path,$data)
{
$method = 'POST';
$fp = fsockopen($host, 80);
fputs($fp, "$method $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp,"Content-type: application/x-www-form- urlencoded\r\n");
fputs($fp, "Content-length: " . strlen($data) . "\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, "Cookie: A9ToolbarRunning=1; A9ToolbarVersion=1.5.0.65; A9ToolbarClientID=2; A9ToolbarSource=A9 \r\n");
while (!feof($fp)) {
$sent .= fgets($fp,128);
}
fclose($fp);
return $sent;
}
/*
usage:
$stringa = "<?xml version="1.0" encoding="UTF-8"?>
<ALEXA VER="0.9" URL="lolbreak.com/" HOME="0" AID="=">
<RLS TITLE="Related Links" PREFIX="http://" more="0">
</RLS>
<SD TITLE="Alexa Site Data" FLAGS="">
<POPULARITY URL="lolbreak.com/" TEXT="1149574"/>
<RANK DELTA="+"/>
<REACH RANK="1371970"/>
</SD>
</ALEXA>"
$sent = sendPost("siteinfo.a9.com","/data/=?cli=10&dat=nsa&pane=amzn&ver=a9-1.5&url=http://www.lol.com/", $stringa);
*/
?>
I made some fixes (mainly correct the comments error and some php syntax), but still not sure if it works.
PHP Code:
<?php
function sendPost($host,$path,$data)
{
$method = 'POST';
$fp = fsockopen($host, 80);
fputs($fp, "$method $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp,"Content-type: application/x-www-form- urlencoded\r\n");
fputs($fp, "Content-length: " . strlen($data) . "\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, "Cookie: A9ToolbarRunning=1; A9ToolbarVersion=1.5.0.65; A9ToolbarClientID=2; A9ToolbarSource=A9 \r\n");
while (!feof($fp)) {
$sent .= fgets($fp,128);
}
fclose($fp);
return $sent;
}
$stringa = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<ALEXA VER=\"0.9\" URL=\"lolbreak.com/\" HOME=\"0\" AID=\"=\">
<RLS TITLE=\"Related Links\" PREFIX=\"http://\" more=\"0\">
</RLS>
<SD TITLE=\"Alexa Site Data\" FLAGS=\"\">
<POPULARITY URL=\"lolbreak.com/\" TEXT=\"1149574\"/>
<RANK DELTA=\"+\"/>
<REACH RANK=\"1371970\"/>
</SD>
</ALEXA>";
$sent = sendPost("siteinfo.a9.com","/data/=?cli=10&dat=nsa&pane=amzn&ver=a9-1.5&url=http://www.lol.com/", $stringa);
?>
One last note, I'm not the owner of the blog, nor do I know if this kind of code is a breach of Alexa's guidelines. I just think is a good idea and it could help have better details on Alexa.
Suggestions welcomed...
Bookmarks