Jump to content

Recommended Posts

Because Mark told me the other day about how people get to your site with various keywords, so I thought it would be fun to make a record of it, these are the major search engines that I had came up with, but I cannot make these on a webpage, because that page wont neccassarily be included in search engines as well, but in case if you are, this is a script to get visitor's search keywords, please feel free to correct any mistake I made.

<?php 
//turn all errors off, security issue
error_reporting(0);
//Key words record from search engines
$referer = $_SERVER['HTTP_REFERER'];
//if search is google
$result = strpos($referer, "google.com");
if (is_int($result) == true) {
$datetime = date("Y-m-d H:i:s");
$pos = strpos($referer, "q=") + 2;
while ($referer{$pos} != "&") {
$key = "$key".$referer{$pos}."";
$pos ++;}
$key = urldecode($key);
echo $key;
$file = fopen("searchengine.txt","a");
$write = fwrite($file,"Google,$datetime,$key\r\n");
fclose($file);}
//if search is msn
$result = strpos($referer, "search.live.com");
if (is_int($result) == false) {$result = strpos($referer, "search.msn.com");}
if (is_int($result) == true) {
$datetime = date("Y-m-d H:i:s");
$pos = strpos($referer, "q=") + 2;
while ($referer{$pos} != "&") {
$key = "$key".$referer{$pos}."";
$pos ++;}
$key = urldecode($key);
echo $key;
$file = fopen("searchengine.txt","a");
$write = fwrite($file,"MSN,$datetime,$key\r\n");
fclose($file);}
//if search is yahoo
$result = strpos($referer, "yahoo.com");
if (is_int($result) == true) {
$datetime = date("Y-m-d H:i:s");
$pos = strpos($referer, "p=") + 2;
while ($referer{$pos} != "&") {
$key = "$key".$referer{$pos}."";
$pos ++;}
$key = urldecode($key);
echo $key;
$file = fopen("searchengine.txt","a");
$write = fwrite($file,"Yahoo,$datetime,$key\r\n");
fclose($file);}
?>

Ted

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.