Answer the question
In order to leave comments, you need to log in
Why does the referral tail not work correctly?
$_SERVER['HTTP_REFERER'] - works if I go from google, but if I go from UTM tag no
$utm = $output['utm_term'] - retrieves the tag adequately
Wrote the snippet Snippet
code:
<?php
@session_start();
if(isset($_SERVER['HTTP_REFERER'])){
if($_SESSION["referer"] == '') $_SESSION["referer"] = $_SERVER['HTTP_REFERER'];
}
//$referer = "http://xxx.ru/xxx?utm_source=yandex&utm_medium=cpc&utm_campaign=17188546&utm_content=1823884480&utm_term=%D0%B1%D0%BB%D0%B5%D1%84%D0%B0%D1%80%D0%BE%D0%BF%D0%BB%D0%B0%D1%81%D1%82%D0%B8%D0%BA%D0%B0&yclid=1826291325305359810"; //(isset($_SESSION["referer"]))? $_SESSION["referer"] : 'Реферальная ссылка не определена' ;
$referer = $_SERVER['HTTP_REFERER'];
if (stristr($referer, 'yandex.ru')) { $search = 'text='; $crawler = 'Yandex'; }
if (stristr($referer, 'rambler.ru')) { $search = 'words='; $crawler = 'Rambler'; }
if (stristr($referer, 'google.ru')) { $search = 'q='; $crawler = 'Google'; }
if (stristr($referer, 'google.com')) { $search = 'q='; $crawler = 'Google'; }
if (stristr($referer, 'mail.ru')) { $search = 'q='; $crawler = 'Mail.Ru'; }
//if (stristr($referer, 'yahoo.com')) { $search = 'q='; $crawler = 'Yahoo'; }
if (stristr($referer, 'bing.com')) { $search = 'q='; $crawler = 'Bing'; }
if (stristr($referer, 'qip.ru')) { $search = 'query='; $crawler = 'QIP'; }
if (isset($crawler)){
$phrase = urldecode($referer);
preg_match('/'.$search.'([^&]*)', $phrase.'&', $phrase_k);
$phrase = $phrase_k[1];
$referer = $crawler;
}
if(isset($crawler)){
echo 'Ключи: '.$phrase.' Источник: '.$referer;
}else{
$phrase = urldecode($referer);
parse_str($referer, $output);
$utm_source = $output['utm_source'];
$utm = $output['utm_term'];
echo ' UTM: '.$utm.' Источник: '.$referer;
}
Answer the question
In order to leave comments, you need to log in
$_GET['utm_term'];
So, like who came for the first time has not yet received your session.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question