Google Analytics(分析) - 追踪页面退出事件(除表格提交外) [英] Google Analytics - Track Event on Page Exit (Except form submission)
本文介绍了Google Analytics(分析) - 追踪页面退出事件(除表格提交外)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用以下代码来跟踪用户何时退出我网站上的页面:
I'm using the following code to track when a user exits a page on my site:
//track on page exit
function storeData(){
_gaq.push(['_trackEvent', 'Application Form', 'exit-form_application_', '', 4, false]);
}
$(window).on('unload',storeData);
然而,我不想在表单提交时触发事件,因此我怎么能阻止这种情况发生?
However, I don't want to trigger the event when the form is submitted, therefore how could I prevent this?
推荐答案
这对我有效:
This worked for me:
$(window).bind('beforeunload', function() {
_gaq.push(['_trackEvent', 'Application Form', 'exit-form_application_', '', 4, false]);
});
$("#formID").submit(function(){
$(window).unbind('beforeunload');
});
这篇关于Google Analytics(分析) - 追踪页面退出事件(除表格提交外)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文