开发者

best way to parse analytics to find referrer?

开发者 https://www.devze.com 2023-01-13 00:27 出处:网络
for example... if(isset($_GET[\'utm_blah\'])) { $referrer = $_GET[\'utm_blah\'; } else { $referrer = $_SERVER[\'HTTP_REFERER\']; }

for example...

if(isset($_GET['utm_blah'])) { $referrer = $_GET['utm_blah'; }
else { $referrer = $_SERVER['HTTP_REFERER']; }

looking to parse referrer sent by google adwords, or twitter, or email, ... etc开发者_StackOverflow. thanks!


A little snippet

if(isset($_SERVER['HTTP_REFERER'])) {
    $in['ref']  = $_SERVER['HTTP_REFERER'];
} 
//...
if(isset($in['ref'])) {
    $found=false;

    /* referrer on same domain ? */
    if(isset($in['domain'])) {
        $refdomain=eregi_replace("^www.","",parse_url($in['ref'],PHP_URL_HOST));
        if($in['domain']==$refdomain) {
            $found=true;
        }
        unset($refdomain);
    }

    /* check referrer ignore list */
    if($found==false && is_file('refferer.ignore.txt') && filesize('refferer.ignore.txt')>0) {
        $ignorelist=explode("\n",file_get_contents('refferer.ignore.txt'));
        $maxi=count($ignorelist);
        if($maxi>0) {
            $i=0;
            while(false===$found && $i
0

精彩评论

暂无评论...
验证码 换一张
取 消