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');
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.