Javascript 如何在没有点击事件的情况下在jQuery中设置分析事件?
我试图在jQuery中设置这样的分析事件Javascript 如何在没有点击事件的情况下在jQuery中设置分析事件?,javascript,jquery,event-handling,google-analytics,Javascript,Jquery,Event Handling,Google Analytics,我试图在jQuery中设置这样的分析事件 jQuery(document).ready(function() { var time_to_open=15000; if(readCookie('cookie')!='set'){ setTimeout(function() { jQuery('#my_animation').animate({left: 0}, 1000); createCookie('cookie', 'set', 1);
jQuery(document).ready(function() {
var time_to_open=15000;
if(readCookie('cookie')!='set'){
setTimeout(function() {
jQuery('#my_animation').animate({left: 0}, 1000);
createCookie('cookie', 'set', 1);
_gaq.push(['_trackEvent', 'animation', 'started', time_to_open]);
},time_to_open);
}
});
这将跟踪动画的显示频率。但它不起作用。
_trackEvent是否仅针对点击事件?或者我做错了什么?如果opt_label参数不是字符串,trackEvent会自动失败。将
time\u to\u open
转换为字符串,或将其作为opt\u值
参数传递
_gaq.push(['_trackEvent', 'animation', 'started', undefined, time_to_open]);
根据
jQuery(document).ready(function() {
var time_to_open = 15000;
if(readCookie('cookie') != 'set') {
var t = window.setTimeout(function() {
jQuery('#my_animation').animate({left: 0}, 1000);
createCookie('cookie', 'set', 1);
_gaq.push(['_trackEvent', 'animation', 'started', 'time_to_open', time_to_open, false]);
}, time_to_open);
}
});
非常感谢两位!