[英]Ajax google analytics event tracking in html page not working
[英]Google analytics custom variables are not working when placed page view tracking in html file and variable tracking in javascript file
我已經為自己的網站實施了Google Analytics(分析)。 當所有代碼都位於.js文件中時,跟蹤代碼可以正常工作。 .js文件包含在我的html頁面的標簽中。
現在,我將代碼分為兩部分。 我將pageView跟蹤放入html文件的標記中,以捕獲准確的加載時間。 然后,我將自定義變量和事件跟蹤放入我的.js文件中。
代碼如下
<head>
<meta http-equiv="Cache-control" content="public">
<meta charset="utf-8">
<title>My web site</title>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-XX']);
_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);
})();
</script>
<script src="js/scripts.js"></script>
</head>
在Scripts.js文件中:
if (_gaq) {
_gaq.push(['_trackEvent', Status, ErrorCode]);
_gaq.push(['_setCustomVar', 1, 'Visitor ID', varVistorID, 3]);
_gaq.push(['_setCustomVar', 2, 'Time Stamp', tStamp.toString(), 3]);
_gaq.push(['_setCustomVar', 3, 'Source', 'online', 3]);
_gaq.push(['_trackPageview']);
}
問題:我並沒有捕獲所有自定義變量。 僅捕獲總訪問量自定義變量的0.03%。 也就是說,如果有35000次訪問,則只捕獲12個訪問者ID,而不是捕獲所有35000個訪問者ID。
在Firefox中,每次訪問頁面時,我都會看到發送到GA的以下值,但報告很少。
utme 5(Success*None) utme 8(Visitor ID*Time Stamp*Source)9(Ravi0408-1210-4aa3-816d-c722203b345c*Tue Apr 08 2014 12:10:48 GMT-0500 (Central Standard Time'1*online)
嘗試從嵌入式腳本中刪除以下行:
gaq.push(['_trackPageview']);
無論如何,您已經在scripts.js文件中重復了它。
您為我信任的訪客使用匿名ID?
trackPageview代碼正確。
要查看網頁級自定義變量 ,您需要明確指定指標和尺寸 ,這可以通過“ 自定義報告” (點擊“自定義”標簽)完成。
默認儀表板將不顯示頁面級自定義變量值。 這是插槽2的自定義變量的自定義報告配置的屏幕截圖:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.