Hi there, as above I have tried to implement a tracking script to log the referring URL (if any) into a database.
The problem: The script seems to be firing recordId() no matter whether it finds the domain name in the referring URL 😕
if(!$_SESSION['referrer'] && $_SERVER["HTTP_REFERER"]) {
$_SESSION['referrer'] = $_SERVER["HTTP_REFERER"];
$referrer = $_SESSION['referrer'];
$string = "domain-name";
if (strpos($referrer, $string) === FALSE) {
recordId();
}
}
function recordId() {
global $conn;
$_SESSION['referrer'] = $_SERVER["HTTP_REFERER"];
$_SESSION['sessionid'] = session_id();
$sql = "INSERT into sessions VALUES ('', '".$_SESSION['referrer']."', '".$_SESSION['sessionid']."')";
mysql_query($sql, $conn) or die("There was an error: <br />".mysql_error());
}
Any help/advice appreciated as always.