// Functions relating to VISITOR TRACKING // version 3.4 - updated April 2011 // (corrected $_SESSION['referrer']; error - 07/04/11) // ---------------------------------------------------------------- // Author: Cornish WebServices - http://www.cornishwebservices.co.uk // Copyright statements to be kept in this file // ---------------------------------------------------------------- // Description: setups the parameters for search tracking code // functions called in tracking.php // $webReferrer deals with lead from natural search listings // $webReferrer2 only used for echoing test messages // function fromCookie($key) { $val = $_COOKIE[$key]; setcookie($key,$val,time()+3600*12*1); // for 3 days return $val; } // grab the source and keyword data from PPC campaigns if(isset($_REQUEST['source'])){ $source = $_REQUEST['source']; // source=adwords / yahoo / msn / content } else { $source = ""; } if(isset($_REQUEST['keyword'])){ $keyword = $_REQUEST['keyword']; // keyword= } else { $keyword = ""; } // do not save when refreshed, otherwise will overwrite the true values if ($source!="") $_SESSION['form0'][0]=$source; if ($keyword!="") $_SESSION['form0'][1]=$keyword; if(isset($_SERVER['HTTP_REFERER'])){ $webReferrer = $_SERVER['HTTP_REFERER']; } else { $webReferrer = ""; } // only update session if not already defined $dom = $_SERVER['HTTP_HOST']; $domLength = strlen($dom); if (($webReferrer=="") ||(substr($webReferrer,7,$domLength)==$dom) ||(substr($webReferrer,8,$domLength)==$dom) ) { // old sesssion so use phone number used before } else { // new session so record referrer $_SESSION['referrer'] = $webReferrer; } $webReferrer2 = $_SESSION['referrer']; ?>