我有一个事件跟踪器(位于 main.js 而不是内联单击处理程序中),它应该在用户单击具有特定类的项目时触发。但是,我的客户报告说这些事件跟踪器永远不会触发,或者至少他从未看到它们的响应。但是,整个站点的其他 GA 事件跟踪器正在工作。任何人都可以看到我下面的代码有任何可能导致这种情况的问题吗?
main.js 中处理此问题的 js 函数如下所示:
$('.vote.complete').click(function()
{
whence = "toCompleted";
vote_id = $(this).data('vote_id');
cid = $(this).data('campaign_id');
c_title = $('#outfitPair'+cid).data('campaign_title');
u_id = $('#outfitPair'+cid).data('other_id');
_gaq = window._gaq;
if(_gaq != undefined){
_gaq.push(['_trackEvent', 'ViewPreviousVote', c_title, u_id]);
}
$('#outfitPair'+cid).find('.button.vote').removeClass('to-vote');
$(this).addClass('to-vote');
$.get('/campaigns/new_pair?whence='+whence+'&vote_id='+vote_id)
return false;
});
被点击的 html 如下所示:
<a href="#" class="button vote complete" data-vote_id="9490" data-campaign_id="5">
<span>01</span>
</a>
我的布局标题中的脚本:
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
_gaq.push(['_setDomainName', 'mywebsite.com']);
_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);
})();
window._gaq = _gaq;
</script>
GA 调试器在加载网页时在我的 js 控制台中返回此信息,尽管当我尝试触发事件跟踪器时没有出现任何新内容:
Registered new plugin: "linker" analytics_debug.js:5
Creating new tracker: t0 analytics_debug.js:5
Sent beacon:
v=1&_v=j11d&a=XXXXXXXXX&t=pageview&_s=1&dl=http%3A%2F%2Fapp.website.com%2Fcampaigns%2Fvote&dr=&ul=en-us&de=UTF-8&dt=Website&sd=32-bit&sr=1366x768&vp=1349x667&je=1&fl=11.8%20r800&_u=MAC~&cid=XX.XX&tid=UA-XXXXXXX-X&z=812880404
analytics_debug.js:5
adSenseId (&a): XXXXXXXXXX analytics_debug.js:5
apiVersion (&v): 1 analytics_debug.js:5
clientId (&cid): XXX.XXX analytics_debug.js:5
encoding (&de): UTF-8 analytics_debug.js:5
flashVersion (&fl): 11.8 r800 analytics_debug.js:5
hitType (&t): pageview analytics_debug.js:5
javaEnabled (&je): 1 analytics_debug.js:5
language (&ul): en-us analytics_debug.js:5
location (&dl): http://app.website.com analytics_debug.js:5
referrer (&dr): analytics_debug.js:5
screenColors (&sd): 32-bit analytics_debug.js:5
screenResolution (&sr): 1366x768 analytics_debug.js:5
title (&dt): Website analytics_debug.js:5
trackingId (&tid): UA-XXXXXXXX-X analytics_debug.js:5
viewportSize (&vp): 1349x667 analytics_debug.js:5