I'm new with UTM (Urchin tracking module) and I want to get the UTM parameters where the user clicked the link from (e.g. facebook, google, twitter) and how many time the user clicked the link with same utm source and save it to the mysql database.
I have a PHP snippet but the utm parameters didn't get and save in the database.
How to fix this?
if(isset($_SERVER['HTTP_REFERER'])){
$utm_source = isset($_GET['utm_source']) ? $_GET['utm_source'] : '';
$utm_medium = isset($_GET['utm_medium']) ? $_GET['utm_medium'] : '';
$utm_campaign = isset($_GET['utm_campaign']) ? $_GET['utm_campaign'] : '';
$utm_term = isset($_GET['utm_term']) ? $_GET['utm_term'] : '';
echo $_SERVER['HTTP_REFERER'];
$sql = "INSERT INTO utm_param(utm_source,utm_medium,utm_campaign)
VALUES('".$conn->real_escape_string($utm_source)."',
'".$conn->real_escape_string($utm_medium)."',
'".$conn->real_escape_string($utm_campaign)."')";
}
utm_param db table structure