jquery - Mixpanel track event failing intermittently -



jquery - Mixpanel track event failing intermittently -

i have few different mixpanel events beingness sent page. couple of them sent upon form submissions (two different forms, each in own modal). of events, 1 of form submission events fails intermittently , can't figure out why. both form submissions have jquery like:

$(document).on 'submit', '#myform', (e) -> mixpanel.track('my form submitted')

one form reliable, other not (it fails 3/4 of time). changed unreliable 1 to:

$(document).on 'submit', '#myform', (e) -> window.mixpanel.track('my form submitted')

and seems work of time, still not always. imagining difference, or changing mixpanel.track window.mixpanel.track have changed something. , oh missing here?

i think caused mixpanels asynchronous behaviour. when phone call submit, track() instruction starts executing in non blocking way, allowing submit form when track() phone call mixpanel api still ongoing. if happens, form submitted before track() phone call completed.

the same thing happening when clicking on links , explained in post. it's reason mixpanel offers track_links() , track_forms() methods. these solve problem follows , may helpful in case.

this function wait 300 ms mixpanel servers respond, if have not responded time head link without ensuring event has been tracked. configure timeout please see mixpanel.set_config docs below.

jquery ruby-on-rails mixpanel

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -