javascript - Google Universal Analytics Form Submit -
i'm trying code javascript snippet tracking form submits, to the lowest degree amount of inconvenience visitor. flow i'm trying programme this.
the user clicks on submit or presses come in submit form (leave comment example). the attached form submit handler catches event , prevent form submitting. the script send google analytics event, upon hitting callback (i don't want utilize timeout method), handler removed , form submittedhowever, problem i'm facing form not (re)submitted upon hitting google analytics callback. handler removed, because submitting form manually sec time results in normal behaviour.
the code have is:
var formsubmithandler = function(event){ event.preventdefault(); ga('send', 'event', 'form submit', 'form submit', 'form submit', {'hitcallback': function () { jquery(event.target).submit(); } }); homecoming false; } jquery( document ).ready(function( $ ) { if (typeof(ga)==='undefined') return; jquery('form').one('submit',formsubmithandler); });
any help in matter appreciated.
you want submit
form, not trigger submit
event again.
please change:
jquery(event.target).submit();
to:
event.target.submit();
javascript jquery forms google-analytics
No comments:
Post a Comment