[英]Google Analytics _gaq.push not working in Firefox
I've a very basic tracking event tied to my login button that's working correctly in Chrome and IE but not in Firefox (v26) 我有一个与登录按钮相关的非常基本的跟踪事件,该事件在Chrome和IE中可以正常运行,但在Firefox(v26)中却无法正常运行
_gaq.push(['_trackEvent', 'Navigation', 'Log In', 'Log In button']);
When a user clicks the login button, their request is authenticated via an Ajax call to the server, if the server responds with a success message, then the this GA code is triggered. 当用户单击登录按钮时,将通过对服务器的Ajax调用对他们的请求进行身份验证,如果服务器以成功消息作为响应,则将触发此GA代码。
No error is reported to the console. 没有错误报告给控制台。
Is there a way to find out if the code fired correctly? 有没有办法找出代码是否正确触发? Or to know if _gaq
has initialised correctly? 还是要知道_gaq
是否已正确初始化?
Use the Google Analytics built-in hitCallback function: 使用Google Analytics(分析)内置的hitCallback函数:
So, on success: 因此,成功了:
_gaq.push(['_set', 'hitCallback' , function(){
//default action
}]);
_gaq.push(['_trackEvent', 'Navigation', 'Log In', 'Log In button']);
Thanks to @Boaz I introduced a delay (50ms) after the GA code fires. 感谢@Boaz,我在GA代码触发后引入了一个延迟(50毫秒)。
_gaq.push(['_trackEvent', 'Navigation', 'Log In', 'Log In button']);
var timeout = 1;
if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1)
timeout = 50;
setTimeout(function() {
//redirect
}, timeout);
Event then fired correctly 事件随后正确触发
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.