Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/430.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在没有点击事件的情况下在jQuery中设置分析事件?_Javascript_Jquery_Event Handling_Google Analytics - Fatal编程技术网

Javascript 如何在没有点击事件的情况下在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中设置这样的分析事件

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]);

根据

  • 类别:动画
  • 操作:已开始
  • 选择标签:打开时间(操作标签)
  • 选择值:15000(整数)
  • 选择非交互:错误
  • 以下是示例:

    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);
       }
    });
    

    非常感谢两位!