2010-10-15 137 views
1

我正在尝试进行自定义报告。 我只是把一些测试代码,我的主页上:分析自定义变量

<script type="text/javascript"> 
    var _gaq = _gaq || []; 
    _gaq.push(['_setAccount', 'UA-12323748-3']); 
    _gaq.push(['_trackPageview']); 
    _gaq.push(['_setCustomVar', 
    2,     // This custom var is set to slot #1 
    'Test_var',  // The name acts as a kind of category for the user activity 
    'Yes',    // This value of the custom variable 
    2     // Sets the scope to session-level 
    ]); 

    (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); 
    })(); 

</script> 

我的自定义报表设置是这样的: http://updo.nl/file/ed351e11.png

然而,它只是出来作为空(我让它收集数据前2天检查报告)

任何帮助,将不胜感激

+0

尝试使用'Custom Variable(Value 2)'而不是'Custom Variable(Key 2)'。 – Yahel 2010-10-15 16:18:11

+0

我做了,但是结果相同 – 2010-10-16 08:32:27

回答

2

我问过很多同样的问题。我被告知必须将setCustomVar行放在trackPageView行的上方,并放在var _gaq行的下面。像这样:

var _gaq = _gaq || []; 
_gaq.push(['_setAccount', 'UA-12323748-3']); 
_gaq.push(['_setCustomVar', 2, 'Test_var', 'Yes', 2]); 
_gaq.push(['_trackPageview']); 

_trackPageview将所有信息发送给Google Analytics,因此您无法在其发送后添加信息。