Good day everyone, In this article we will learn how to catch information from “HTTP_REFERER” function such as, referer info, keyword info, etc. From some search engine using PHP snippet. This script might usefully when you want to analyze your keyword and referer statistic. Last night I was searching in WP plugin for this script but I didn’t found one really good.

So let’s created it our self, First, You need this PHP class save it as searchkeys.class.php

<?php

class search_keywords
{
var $referer;

var $search_engine;

var $keys;

var $sep;

function search_keywords()
{
$this->referer = ”;
$this->sep = ”;

if ($_SERVER['HTTP_REFERER'] OR $_ENV['HTTP_REFERER'])
{
$this->referer = urldecode(($_SERVER['HTTP_REFERER'] ? $_SERVER['HTTP_REFERER'] : $_ENV['HTTP_REFERER']));
$this->sep = (eregi(‘(\?q=|\?qt=|\?p=)’, $this->referer)) ? ‘\?’ : ‘\&’;
}
}

function get_keys()
{
if (!empty($this->referer))
{
if (eregi(‘www\.google’, $this->referer))
{
// Google
preg_match(“#{$this->sep}q=(.*?)\&#si”, $this->referer, $this->keys);
$this->search_engine = ‘Google’;
}
else if (eregi(‘(yahoo\.com|search\.yahoo)’, $this->referer))
{
// Yahoo
preg_match(“#{$this->sep}p=(.*?)\&#si”, $this->referer, $this->keys);
$this->search_engine = ‘Yahoo’;
}
else if (eregi(‘search\.msn’, $this->referer))
{

// MSN
preg_match(“#{$this->sep}q=(.*?)\&#si”, $this->referer, $this->keys);
$this->search_engine = ‘MSN’;
}
else if (eregi(‘www\.alltheweb’, $this->referer))
{
// AllTheWeb
preg_match(“#{$this->sep}q=(.*?)\&#si”, $this->referer, $this->keys);
$this->search_engine = ‘AllTheWeb’;
}
else if (eregi(‘(looksmart\.com|search\.looksmart)’, $this->referer))
{
// Looksmart
preg_match(“#{$this->sep}qt=(.*?)\&#si”, $this->referer, $this->keys);
$this->search_engine = ‘Looksmart’;
}
else if (eregi(‘(askjeeves\.com|ask\.com)’, $this->referer))
{
// AskJeeves
preg_match(“#{$this->sep}q=(.*?)\&#si”, $this->referer, $this->keys);
$this->search_engine = ‘AskJeeves’;
}
else
{
$this->keys = ‘Not available’;
$this->search_engine = ‘Unknown’;
}
return array(
$this->referer,
(!is_array($this->keys) ? $this->keys : $this->keys[1]),
$this->search_engine
);
}
return array();
}
}

?>

Now you have the classes, you can use this example PHP script to shown the result, save it as blabla.php $keys[3] will shown information about full referer URL so you can add or remove it.

<?php

require_once(‘./searchkeys.class.php’);

$keys =& new search_keywords();
$keys = $keys->get_keys();

if (count($keys))
{
echo “You’re directed to this page from <b>$keys[2]</b> search engine, within Keywords <b>’$keys[1]‘</b>”;
}

?>

Now you can add this snippet to your page, The result is same like this screen shoot(blue box):

php-se-keyword-catch

Done, I hope someone would created WP plugins using this script and added some feature. That would be nice he he :)

Download the package here!

    Digg Del.icio.us StumbleUpon Reddit Twitter RSS

SIMILAR POST :

Incoming search terms:

  • php detectar referer adwords
  • google catch search words
  • get referer search key google php
  • php get search engine and keywords
  • detect search engine referral
  • catching keywords search engines
  • parsing seo from referrer
  • capture search engine keywords in php
  • capture keywords on my site php
  • php suchbegriffe aus referer ermitteln
  • php parser google adwords keyword
  • php parse referring keywords
  • php parse referrer search engine
  • php google refer keyword
  • php google referrer key phrase
  • php keyword referral
  • php keyword parser
  • php google normal referer adwords
  • php get search engine keyword preg_match
  • php get search engine keyword
  • php code to find key keywords in google
  • php détection keyword
  • php detect adwords refer
  • php detect keywords
  • php detect search engine and keyword
  • php detectar keyword referrer
  • php extracting keywords from referrer
  • php find keywords in string
  • php get google keyword idea
  • php get keywords from search engine referer url
  • php code for keyword position in google
  • php recognise adwords
  • referring keyword display script
  • retrieve search keywords in asp
  • save search keywords php
  • saving the google referrer keyword
  • script referrer Search list keywords
  • search englines referal keywords using PHP
  • search keywords in php
  • vba parse google referrer strings
  • website php capture adwords keywords
  • what is my referer and google keywords
  • referral keywords from google script save
  • referal keyword php
  • recognising adwords in referer
  • php recognise referral from google
  • php recognize adwords
  • php referrer google keywords class
  • php save keyword function refer from google search
  • php saving search keywords
  • php script save google keywords
  • php search referrer key
  • PHP: get keywords from search engine referer url
  • preg_match google url_referer
  • preg_match referrer from google adwords
  • wordpress plugin keyword referrer
  • $get php suchbegriffe referer
  • detect referer cpc organic
  • detect search engine and query from referrer
  • detect search engine keyowrds php
  • detect search engine keyword in php
  • detect search engine referrer php
  • detectar referer adwords organic cpc
  • detecting adwords referers
  • display last google referrer keywords wordpress
  • extract keyword referrer
  • extract keyword referrer url
  • detect google referrer
  • detect google keywords
  • abn amro bursa efek jakarta alamat
  • adwords extract keywords script from referrer
  • adwords searchterm php
  • can save keyword in php
  • catch google keyword php
  • catching keywords from search engines
  • code php search again for domain
  • detect google ad referer
  • detect google adwords referers
  • detect google analytics preg_match
  • extract referer keywords php google 2011
  • get bing search terms referer php
  • get keyword by referer
  • lokasi bank of america jakarta
  • parse google search referral
  • parse html php analyzing keywords
  • parse keyword in php
  • parsing google referrer string to get search key
  • php adwords google keyword various word
  • php capture search engine keywords
  • php check refer is from adwords
  • php class google search referrer keywords redirect
  • php class search_keywords not working keywords empty
  • keywords search engine preg_match_all php
  • keywords positions php script
  • get refferer keywords wordpress
  • get search engine referral keyword script
  • getsearchenginekeywords
  • google adwords fetch referrer keyword
  • google реферер keyword
  • google searches related to preg_match_all(
  • googleadwords php class
  • how get search engine position from referer
  • how to parse google referer php
  • keyword referer script
  • php class to parse search engine referral strings

If you're new here, you may want to subscribe to my RSS feed. You may copy or publish this article to your blog or other site as long you give credit link back to this site article. Thanks for visiting my blog!