|
Post by Jacob on Jun 12, 2009 14:43:39 GMT -5
Keyword Grabber analyzes the referrer and looks for search engine keywords. It has been tested on Google, Yahoo, Ask, and MSN, and will work on any search engine that uses q or p as the query parameter containing the keyword. New parameters to search for can be added easily. It does not come with any logging code (by default it prints the keyword to the screen) but that can be easily added. To install, all one needs to do is include the file in all the pages to be tracked.
To add new keywords, edit the script and add to the $tolookfor array, adding the parameter prefixed with both ? and &. A comment indicated where to place the logging code or any other code that should be executed when a keyword is found.
<?php if(isset($_SERVER['HTTP_REFERER'])) { $ref = $_SERVER['HTTP_REFERER']; $tolookfor = array('?p', '&p', '?q', '&q'); //Add new GET parameters to look for here for($i = 0; $i < count($tolookfor); $i++) { if(stristr($ref, $tolookfor[$i].'=')) { $pos = strpos($ref, $tolookfor[$i].'=') + strlen($tolookfor[$i]) + 1; $str1 = substr($ref, $pos); $pos2 = strpos($str1, '&'); $keyword = substr($str1, 0, $pos2); } } if(isset($keyword)) { //Enter your logging code here, removing the below line if desired echo $keyword; } } ?>
|
|