3

_trackEvent()在 Google Analytics 中为文件下载添加了一个跟踪事件,但它不起作用。我已经等了 24 小时,等待 Google Analytics 上的事件跟踪更新。我的代码是:

<a class="buttonstyle" href="/DownloadDocuments/WINTER_2012_Magazine_visual.pdf" target="_blank"     onclick="return documentDownload(this, 'WINTER_2012_Magazine_visual.pdf');">Download</a>

<script>
function documentDownload(link, downloadFileName) {
_gaq.push(['_trackEvent', 'Downloads', 'Click', downloadFileName]);
setTimeout('document.location = "' + link.href + '"', 500);

return false;
}
</script>

我已经检查了控制台,这对我来说看起来不错:

_gaq.push processing "_trackEvent" for args: "[Downloads,Click,WINTER_2012_Magazine_visual.pdf]":    ga_debug.js:18
Track Event ga_debug.js:18
Tracking beacon sent!
utmwv=5.3.8d&utms=15&utmn=1916071374&utmhn=www.testmarketingstore.co.uk&utmt=event&utme=5(Downloads*Click*WINTER_2012_Magazine_visual.pdf)&utmcs=UTF-8&utmsr=1920x1080&utmvp=1903x955&utmsc=32-bit&utmul=en-gb&utmje=1&utmfl=11.5%20r31&utmdt=Test%20Marketing%20Store&utmhid=972203903&utmr=-&utmp=%2Fasp%2Fca%2Fced.asp%3FdisplayType%3Ddocs%26searchCriteria%3Duseful&utmac=UA-XXXXX-X&utmcc=__utma%3D231962136.231857795.1353415477.1353932330.1353939554.6%3B%2B__utmz%3D231962136.1353415477.1.1.utmcsr%3D(direct)%7Cutmccn%3D(direct)%7Cutmcmd%3D(none)%3B&utmu=yAAAAAAAAC~ ga_debug.js:18
Account ID               : UA-XXXXX-X
Page Title               : Test Marketing Store
Host Name                : www.testmarketingstore.co.uk
Page                         : /asp/ca/ced.asp?displayType=docs&searchCriteria=useful
Referring URL            : -
Hit ID                   : 972203903
Hit Type                 : event
Event Name               : Downloads
Event Type               : Click
Event Label              : WINTER_2012_Magazine_visual.pdf
Visitor ID               : 231857795
Session Count            : 6
Session Time - First     : Tue Nov 20 2012 12:44:37 GMT 0000 (GMT Standard Time)
Session Time - Last      : Mon Nov 26 2012 12:18:50 GMT 0000 (GMT Standard Time)
Session Time - Current   : Mon Nov 26 2012 14:19:14 GMT 0000 (GMT Standard Time)
Campaign Time            : Tue Nov 20 2012 12:44:37 GMT 0000 (GMT Standard Time)
Campaign Session         : 1
Campaign Count           : 1
Campaign Source          : (direct)
Campaign Medium          : (none);
Campaign Name            : (direct)
Language                 : en-gb
Encoding                 : UTF-8
Flash Version            : 11.5 r31
Java Enabled             : true
Screen Resolution        : 1920x1080
Browser Size             : 1903x955
Color Depth              : 32-bit
Ga.js Version            : 5.3.8d
Cachebuster              : 1916071374 

谁能给我一些关于如何追踪问题的建议?

4

2 回答 2

5

您将旧式同步分析代码(在您的分析代码片段中)与新式异步代码(在您的事件跟踪中)混合在一起。因此,_trackEvent呼叫使用具有默认 UA-XXXXX-X UID 的分析跟踪器。

两个选项:将事件跟踪代码更改为同步代码:

function documentDownload(link, downloadFileName) {
  pageTracker._trackEvent('Downloads', 'Click', downloadFileName);
  setTimeout('document.location = "' + link.href + '"', 500);
  return false;
}

或将 Google 分析代码更新为异步样式:

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-464435-4']);
_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>
于 2012-11-26T16:07:54.533 回答
0

您还应该发送 _gaq.push(['_setAccount', 'UA-XXXXXX-1']); 在跟踪事件之前并为 chrome 安装此扩展程序以调试 https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna

它对我们有用

于 2014-06-09T14:07:32.603 回答