2010-10-15 131 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,因此您無法在其發送後添加信息。