Hi, I've seen this done in a plugin for wordpress and would like to accomplish the same with a regular site. What I would like to do is create a PHP script that displays the referring search engine and keyword that was used to find my site. So say someone found my site using Google and used the keyword "widgets" I could display the words for the referring engine (Google) and the keyword (widgets) on the webpage somewhere. I'm useless at PHP , but could anyone point out if this is easy to create? Thanks for any replies.
This is a pretty simple version, but it ought to do the trick. if(strpos($_SERVER['HTTP_REFERER'], "google.com/search") !== false){ $keyword = array_pop(explode("&q=", $referer)); echo(htmlentities(urldecode($keyword))); } PHP:
Thanks Fash, this currently doesn't display anything on the page when I test being referred from Google though. I'll try and look a bit further into this and see what the problem might be. This looks exactly what I need (with MSN and Yahoo included) so I'm eager to get this working. Thanks for the help.
$referer is not defined unless you have register_globals on. if(strpos($_SERVER['HTTP_REFERER'], "google.com/search") !== false) { $keyword = array_pop(explode("&q=", $_SERVER['HTTP_REFERER'])); echo(htmlentities(urldecode($keyword))); } PHP: