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
  • capture search engine keywords in php
  • get referer search key google php
  • detect search engine referral
  • php get search engine and keywords
  • php parse adwords referral ur;
  • catching keywords search engines
  • parsing seo from referrer
  • capture keywords on my site php
  • php detect keywords
  • php code to find key keywords in google
  • php google normal referer adwords
  • php google refer keyword
  • php code for keyword position in google
  • php google referrer key phrase
  • php how to retrieve keyword referral
  • php keyword parser
  • php keyword referral
  • php class to parse search engine referral strings
  • php get search term from referral
  • php get search engine keyword preg_match
  • php detect organic from referer
  • php detect search engine and keyword
  • php detectar keyword referrer
  • php extracting keywords from referrer
  • php find keywords in string
  • php detect adwords refer
  • php get keywords from search engine referer url
  • php détection keyword
  • php get search engine keyword
  • php get google keyword idea
  • php parse referrer search engine
  • php parse referring keywords
  • referal keyword php
  • referral keywords from google script save
  • referring keyword display script
  • retrieve search keywords in asp
  • save search keywords php
  • saving the google referrer keyword
  • script referrer Search list keywords
  • wordpress plugin keyword referrer
  • search englines referal keywords using PHP
  • search keywords in php
  • vba parse google referrer strings
  • website php capture adwords keywords
  • recognising adwords in referer
  • preg_match referrer from google adwords
  • php parser google adwords keyword
  • php recognise adwords
  • 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 suchbegriffe aus referer ermitteln
  • PHP: get keywords from search engine referer url
  • preg_match google url_referer
  • what is my referer and google keywords
  • php class search_keywords not working keywords empty
  • $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 from Adwords referral url
  • extract keyword referrer
  • extract keyword referrer url
  • detect google referrer
  • detect google keywords
  • detect google analytics preg_match
  • abn amro bursa efek jakarta alamat
  • adword referer keyword
  • adwords extract keywords script from referrer
  • adwords searchterm php
  • can save keyword in php
  • catch google keyword php
  • catching keywords from search engines
  • check google adwords referer php
  • code php search again for domain
  • detect google ad referer
  • detect google adwords referers
  • extract referer keywords php google 2011
  • get bing search terms referer php
  • keywords search engine preg_match_all php
  • lokasi bank of america jakarta
  • parse google search referral
  • parse html php analyzing keywords
  • parse keyword in php
  • parse search phrase term referral url
  • parsing google referrer string to get search key
  • php adwords google keyword various word
  • php capture search engine keywords
  • php catch google referers
  • php check refer is from adwords
  • keywords positions php script
  • keyword referer script
  • how to parse google referer php
  • get keyword by referer
  • get referer google adwords php
  • 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 catch keywords from search engine
  • php class google search referrer keywords redirect

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!