解析分析以找到引用者的最佳方法?

时间:2010-08-24 05:59:53

标签: php google-analytics analytics

例如......

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

希望解析谷歌adwords,推特或电子邮件发送的推荐人,等等!谢谢!

1 个答案:

答案 0 :(得分:1)

一个小片段

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