Hi,
I've recently taken over running a website for a company and they have a piece of code which changes the phone number based on where the visitor came from, and includes the source and keyword information when a visitor submits a form.
Here is the current code (modified for anonymity)
session_start();
if(!isset($_SESSION["phonenumber"]))
{
if(isset($_SERVER['HTTP_REFERER']))
{
//not direct, must be PPC or Natural
if(isset($_GET["gcid"]))
{
//must be PPC
$_SESSION["keyword"] = $_GET["keyword"];
if(isset($_GET["gclid"]))
{
$_SESSION["phonenumber"] = "00000000000"; //PPC
$_SESSION["keyword"] = "GOOGLE PPC -> " . $_SESSION["keyword"];
}
else
{
if(strpos($_SERVER['HTTP_REFERER'],'yahoo') > 0)
{
$_SESSION["phonenumber"] = "00000000000"; //PPC
$_SESSION["keyword"] = "YAHOO PPC -> " . $_SESSION["keyword"];
}
else
{
$_SESSION["phonenumber"] = "00000000000"; //PPC
$_SESSION["keyword"] = "MSN PPC -> " . $_SESSION["keyword"];
}
}
}
else
{
//natural
$_SESSION["phonenumber"] = "00000000000"; //NATURAL
$referer = "";
if(isset($_SERVER['HTTP_REFERER']));
$referer = $_SERVER['HTTP_REFERER'];
$_SESSION["keyword"] = "Natural -> " . $referer;
}
}
else
{
// direct
$_SESSION["keyword"] = "Direct";
$_SESSION["phonenumber"] = "00000000000"; //DIRECT
}
}
What I am wondering is how to add four additional entries to this for 4 different numbers:
- Traffic redirected from www.example.com (forwarded domain)
- Traffic redirected from www.example2.com (forwarded domain)
- Traffic to www.ourdomain.com/specificpage1.php
- Traffic to www.ourdomain.com/specificpage2.php
All links coming to the website using one of these 4 options will be using google analytics tagged links (including domain forwards), so will contain common parts of the URL if it can be changed using tags like ?utm_source="oursource"
I'm still new to PHP and while I understand what this piece of code is doing, I don't fully understand how it works so would appreciate any guidance people could give me.
Thanks,
Sicsiksix