Wordpress plugin to log SE traffic (and improve your ranking)
Ever thought of using keywords that already gave you some traffic to promote site page instead of keywords it was originally designed for? I did. So what I needed was a way to get the SE terms that gave some traffic to a WP based site. Of course, the first thought was to get them from external statistics sources - Awstats, for instance. However, even though I found a way to make Awstats separate terms by search engine, I never managed to make changes to the configuration file (stupid hostgator support)… So I just made a WP plugin to add the terms SE separated into the DB and add those terms to the beginning of the post in the user-defined format. So you install it, check the needed format (or disable adding those lines at all, if you just need an insight into the keywords or plan to improve the plugin by adding XMLRPC method to download keywords from external script). Download, free, of course
Here is a sample code (just for SEs :))
function selog_log() {
if (is_admin()) return true;
// echo '<pre>'; print_r($_SERVER); echo '</pre>';
@$ref = $_SERVER['HTTP_REFERER'];
if (!$ref) return true;
$ses = array(’www.google.com’, ’search.yahoo.com’, ’search.live.com’, ’search.msn.com’);
$ref = parse_url($ref);
if (!in_array($ref['host'], $ses)) return true;
$query = $ref['query'];
parse_str($query, $query);
$keyword = $query['q'] or
$keyword = $query['p'];
$ru = $_SERVER['REQUEST_URI'];
selog_prep($ru);
selog_prep($keyword);
list(,$se,) = explode(’.', $ref['host']);
global $wpdb;
$selog = $wpdb->prefix.selog;
$id = $wpdb->get_var(”SELECT `id` FROM `$selog` WHERE `url` = ‘$ru’ AND `keyword` = ‘$keyword’ AND `se` = ‘$se’”);
if ($id) {
$wpdb->query(”UPDATE `$selog` SET `cnt` = `cnt` + 1 WHERE `id` = $id”);
} else {
if (is_single()) {
global $post;
$pid = “, `postid` = $post->ID”;
} else $pid = ”;
$wpdb->query(”INSERT INTO `$selog` SET `url` = ‘$ru’, `keyword` = ‘$keyword’, `se` = ‘$se’$pid, `cnt`=1″);
}
//http://www.google.com/search?hl=en&q=how+to+get+rid+of+standing+water+in+your+yard
//http://search.yahoo.com/search;_ylt=A0geu8n.JC9IfDcBARNXNyoA?p=duane+barney+tents+website&fr=slv8-
//http://search.live.com/results.aspx?q=reading&mrt=en-us&FORM=LIVSOP
//http://search.msn.com/results.asp?FORM=sCPN&RS=CHECKED&un=doc&v=1&q=scriptures%20prosperity
}