03-04-2012, 12:59 AM
Code:
<?php
$referer= $_SERVER['HTTP_REFERER'];
//find the search query from google that brought them here
$qref= strpos($referer,’google’);
if($qref!=”){
$qstart = strpos($referer,’q=’);
$qend = strpos($referer,’&’,$qstart);
$qtext= substr($referer,$qstart+2,$qend-$qstart-2);
$qtext= str_replace(‘+’,’ ‘,$qtext);
}
echo $qtext
?>
Notes:if someone reaches your site via google it will show the keyword that the user has typed in google