4
以下是在HTML頁面關閉/ head之前添加的Google Analytics代碼。Ajax谷歌分析事件跟蹤HTML頁面不起作用
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-x']);
_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);
})();
以下是我在哪裏調用事件......成功或失敗的時候......
$.ajax({
url: "/xxx/xx/",
type: "POST",
data: { name: q, seme: o, profile: x }
datatype: "html",
success: function (f) {
_gaq && _gaq.push(["_trackEvent", "contactform", "success", i, p])
},
error: function (f) {
_gaq && _gaq.push(["_trackEvent", "contactform", "crash", i, p])
}
});
但沒有記錄的情況下......我一直在等着看過去的東西4天..我已經進行了一些測試,但沒有顯示在分析中......我做錯了什麼?是否必須在頭標記中添加的Google Analytics主要代碼段中添加任何額外的行?
GA跟蹤正常數據,但不是這些事件。
_gaq && ...通過js壓縮輸出。其實如果(_gaq)...我會用ga_debug測試並更新線程。謝謝。 –
謝謝,不知道ga_debug。安裝了一個chrome插件,發現我在第四個參數(p,在這種情況下)中發送一個字符串,其中ga需要一個整數。 –
鏈接到Chrome擴展程序:https://chrome.google.com/webstore/detail/jnkmfdileelhofjcijamephohjechhna – kalenjordan