1

我正在使用以下脚本将数据从表单发送到谷歌分析:

if ($result){
        $var_utmac = 'UA-0000000-0';
        $var_utmhn = 'my-site.com'; // domain
        $var_utmn = rand(1000000000,9999999999); // random number
        $var_cookie = rand(10000000,99999999); //random cookie number
        $var_random = rand(1000000000,2147483647); //number under 2147483647
        $var_today = time();
        $var_referer = $_SERVER['HTTP_REFERER']; //referer url
        if ($var_referer == '') { $var_referer = '-'; }
        $var_uservar='-'; // no user-defined
        $var_utmp= $_POST['REQUEST_URI'].'data_'.  htmlentities($_POST['dataone']).'_'.htmlentities($_POST['datatwo']); // folder called no_jstracker to segment nojavascript visitors
        $urchinUrl='http://www.google-analytics.com/__utm.gif?utmwv=3&utmn=' . $var_utmn . '&utme=&utmcs=-&utmsr=-&utmsc=-&utmul=-&utmje=0&utmfl=-&utmdt=-&utmhn=' . $var_utmhn . '&utmhid=' . $var_utmn . '&utmr=' . $var_referer . '&utmp=' . $var_utmp . '&utmac=' . $var_utmac . '&utmcc=__utma%3D' . $var_cookie . '.' . $var_random . '.' . $var_today . '.' . $var_today . '.' . $var_today . '.2%3B%2B__utmz%3D' . $var_cookie . '.' . $var_today . '.2.2.utmcsr%3D_SOURCE_%7Cutmccn%3D_CAMPAIGN_%7Cutmcmd%3D_MEDIUM_%7Cutmctr%3D_KEYWORD_%7Cutmcct%3D_CONTENT_%3B%2B__utmv%3D' . $var_cookie . '.' . $var_uservar . '%3B';
        echo ' <img src="' . $urchinUrl . '" border="0" />';
    }

虽然数据被成功发送,但存在一个问题,那就是分析没有正确显示某些数据,即对于活动数据,它只是为关键字提供“ CAMPAIGN ”,它显示“ KEYWORD ”。很清楚这在脚本中发生的位置,但不知道如何修复它。理想情况下,当然分析应该用自己的数据填充它。

任何建议这是否可能?

4

1 回答 1

0

我认为这是因为您硬编码了“CAMPAIGN”值。而不是为广告系列分配价值。

$CAMPAIGN='facebook';
$KEYWORD='testing';
$urchinUrl='http://www.google-analytics.com/__utm.gif?utmwv=3&utmn=' . $var_utmn . '&utme=&utmcs=-&utmsr=-&utmsc=-&utmul=-&utmje=0&utmfl=-&utmdt=-&utmhn=' . $var_utmhn . '&utmhid=' . $var_utmn . '&utmr=' . $var_referer . '&utmp=' . $var_utmp . '&utmac=' . $var_utmac . '&utmcc=__utma%3D' . $var_cookie . '.' . $var_random . '.' . $var_today . '.' . $var_today . '.' . $var_today . '.2%3B%2B__utmz%3D' . $var_cookie . '.' . $var_today . '.2.2.utmcsr%3D_SOURCE_%7Cutmccn%3D'.$CAMPAIGN.'%7Cutmcmd%3D_MEDIUM_%7Cutmctr%3D'.$KEYWORD.'%7Cutmcct%3D_CONTENT_%3B%2B__utmv%3D' . $var_cookie . '.' . $var_uservar . '%3B';

有关Google Analytics Cookie的更多详细信息

于 2012-11-09T10:10:49.000 回答