jQuery追踪谷歌分析事件无效 [英] jQuery to track Google analytics events not working

查看:86
本文介绍了jQuery追踪谷歌分析事件无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在做的是使用jQuery加载函数$ b加载5个页面$ b,我想跟踪每个负载的下一步按钮。但看起来像我做错了什么。



这是下一个按钮事件代码:



<$ p $点击(功能(){
_gaq.push(['_ trackEvent','fz_main_page','点击'));
安装($'code> $('。NextButton' .load_page({inner_page:next_page,comid:data.comid,outerid:data.outerid,single_app:1});
});

分析代码:

 < script type =text / javascript> 
var _gaq = _gaq || [];
_gaq.push(['_ setAccount','UA-25162785-2']);
_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 =文档.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga,s);
})();
< / script>

我做错了什么?

解决方案

installation.load_page 函数可能会阻止 trackEvent 触发。尝试在 setTimeout 中包装 load 函数:



<$ p $ {p> setTimeout('installation.load_page({inner_page:next_page,comid:data.comid,outerid:data.outerid,single_app:1})',100);

安装 Google Analytics调试器。查看控制台(控件,shift,j)以进行事件跟踪处理。



如果你没有看到你所有的事件都在那里跟踪,那么跟踪代码就会出现其他问题。

I'm trying to use google anayltics events but so far without any success..

What I'm doing is loading 5 pages using jQuery load function and I want to track the "Next button" for each load. but looks like i'm doing something wrong..

This is the next button event code:

            $('.NextButton').click(function () {
                _gaq.push(['_trackEvent', 'fz_main_page', 'clicked']);
                installation.load_page({ inner_page: next_page, comid: data.comid, outerid: data.outerid, single_app: "1" });
            });

Analytics Code:

<script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-25162785-2']);
    _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>

What am I doing wrong?

解决方案

It's possible that the installation.load_page function is preventing the trackEvent from firing. Try wrapping your load function in a setTimeout:

setTimeout('installation.load_page({ inner_page: next_page, comid: data.comid, outerid: data.outerid, single_app: "1" })', 100);

Install the Google Analytics Debugger. Look in the console (control, shift, j) for the event tracking processing.

If you don't see all of your events tracking there, then something else is up with the tracking code.

这篇关于jQuery追踪谷歌分析事件无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆