Google Analytics自定义变量仅跟踪最后一个密钥

时间:2014-02-27 19:07:47

标签: google-analytics

我对GA和自定义变量有一些经验,而我认为没有改变的代码昨天停止工作。它很简单,这是在网站上运行的确切代码(减去UA代码和域。)奇怪的是,GA现在只接受在特定插槽中设置的最后一个变量。

我有这段代码:

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxx']);
_gaq.push(['_setCustomVar',2,'test1','testvalue1',2]);
_gaq.push(['_setCustomVar',2,'test2','testvalue2',2]);
_gaq.push(['_setCustomVar',2,'test3','testvalue3',2]);
_gaq.push(['_trackPageview']);

(function() {
 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

哪个应跟踪GA中的四个自定义变量。但是,只跟踪FINAL变量。这是输出:

_gaq.push processing "_setAccount" for args: "[UA-18327050-3]":  ga_debug.js:24
_gaq.push processing "_setCustomVar" for args: "[2,test1,testvalue1,2]":  ga_debug.js:24
_gaq.push processing "_setCustomVar" for args: "[2,test2,testvalue2,2]":  ga_debug.js:24
_gaq.push processing "_setCustomVar" for args: "[2,test3,testvalue3,2]":  ga_debug.js:24
_gaq.push processing "_trackPageview" for args: "[]":  ga_debug.js:24
Track Pageview ga_debug.js:24
Tracking beacon sent!
utmwv=5.4.7d&utms=108&utmn=1896343294&utmhn=xxxdomain.com&utme=8(2!test3)9(2!testvalue3)11(2!2)&utmcs=ISO-8859-1&utmsr=1366x768&utmvp=1366x46&utmsc=24-bit&utmul=en-us&utmje=1&utmfl=12.0%20r0&utmhid=1416834004&utmr=-&utmp=%2Ftest.php&utmht=1393527804008&utmac=UA-18327050-3&utmcc=__utma%3D211559050.1602513162.1393521508.1393521508.1393521508.1%3B%2B__utmz%3D211559050.1393521508.1.1.utmcsr%3D(direct)%7Cutmccn%3D(direct)%7Cutmcmd%3D(none)%3B&utmu=qQ~ ga_debug.js:24
Account ID               : UA-xxx-3
Host Name                : xxxdomain.com
Page                     : /test.php
Referring URL            : -
Hit ID                   : 1416834004
Visitor ID               : 1602513162
Session Count            : 1
Session Time - First     : Thu Feb 27 2014 07:18:28 GMT-1000 (Hawaiian Standard Time)
Session Time - Last      : Thu Feb 27 2014 07:18:28 GMT-1000 (Hawaiian Standard Time)
Session Time - Current   : Thu Feb 27 2014 07:18:28 GMT-1000 (Hawaiian Standard Time)
Campaign Time            : Thu Feb 27 2014 07:18:28 GMT-1000 (Hawaiian Standard Time)
Campaign Session         : 1
Campaign Count           : 1
Campaign Source          : (direct)
Campaign Medium          : (none);
Campaign Name            : (direct)
Custom Var 2             : label:'test3' value:'testvalue3' scope:'2'
Language                 : en-us
Encoding                 : ISO-8859-1
Flash Version            : 12.0 r0
Java Enabled             : true
Screen Resolution        : 1366x768
Browser Size             : 1366x46
Color Depth              : 24-bit
Ga.js Version            : 5.4.7d
Cachebuster              : 1896343294 

1 个答案:

答案 0 :(得分:2)

您设置的每个自定义变量的索引均为2.使用其他索引,例如1,3,4或5。

例如:

_gaq.push(['_setCustomVar',1,'test1','testvalue1',2]);
_gaq.push(['_setCustomVar',2,'test2','testvalue2',2]);
_gaq.push(['_setCustomVar',3,'test3','testvalue3',2]);