2013-04-17 60 views
2

我正在嘗試使用以下腳本將Google的事件跟蹤集成到我的應用程序中。我可以在「實時」標籤中看到事件。但我無法在「內容」標籤中看到這些事件。事件跟蹤不起作用

var _gaq = _gaq || []; 
    _gaq.push(['_setDomainName', 'none']); 
    _gaq.push(['_setAccount', 'XXXXX']); 
    _gaq.push(['_trackPageview']); 
    _gaq.push(['_trackEvent', 'request.fullpath', 'plan_desc', 'plan_code>']); 

Events Under Realtime Tab

Events Under Content Tab

+0

Google Analytics報告中的數據最長可能需要48小時才能處理,具體取決於您的帳戶規模。你等了多久? – Eduardo

+0

我等了大約24小時 – loganathan

+1

任何東西在控制檯?谷歌有一個標籤助手Chrome插件,它可以在這裏找到,它可以幫助你調試。 https://chrome.google.com/webstore/detail/tag-assistant-by-google/kejbdjndbnbjgmefkgdddjlbokphdefk?hl=zh-CN – Stoosh

回答

3

你抓住定義GAQ功能的腳本?

var _gaq = _gaq || []; 
    _gaq.push(['_setDomainName', 'none']); 
    _gaq.push(['_setAccount', 'XXXXX']); 
    _gaq.push(['_trackPageview']); 
    _gaq.push(['_trackEvent', 'request.fullpath', 'plan_desc', 'plan_code>']); 
(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); 
})(); 

另外,對於您的事件推送,您推送的值應該是JS對象嗎?如果是這樣,你可能想擺脫引號。

0

如果你要使用Rails的變量在JS,如request.fullpath看起來像一個你必須確保你出來渲染它在你的模板引擎。例如,如果你正在使用ERB,你必須把它像這樣...

_gaq.push(['_trackEvent', '<%= request.fullpath %>', 'plan_desc', 'plan_code>']); 

顯然重複對其他變量,如果他們不Ruby和是純JS對象,你需要省略報價在他們周圍標記。

2

在將實時看到的數據轉換爲其他部分之前,GA需要一段時間。

如果您只在48小時內添加了代碼,結果尚未準備好查看,則可能是這樣。