我的页面发送了一些不同的mixpanel事件.在提交表单时会发送其中的几个表单(两个不同的表单,每个表单都有自己的模式).在所有事件中,表单提交事件之一间歇性失败,我不知道为什么.两种表单提交都具有jQuery,如:
I have a few different mixpanel events being sent from my page. A couple of them are sent upon form submissions (two different forms, each in its own modal). Of all the events, one of the form submission events fails intermittently and I can't figure out why. Both form submissions have jQuery like:
$(document).on 'submit', '#myForm', (e) -> mixpanel.track('my form submitted')一种形式是可靠的,另一种形式是不可靠的(大约3/4的时间失败).我将不可靠的更改为:
One form is reliable, the other is not (it fails about 3/4 of the time). I changed the unreliable one to:
$(document).on 'submit', '#myForm', (e) -> window.mixpanel.track('my form submitted'),它似乎在大多数时间都有效,但仍然不总是如此.我是在想象差异,还是将mixpanel.track更改为window.mixpanel.track可能有所改变.哦,我在这里想念什么?
and it seems to work most of the time, but still not always. Am I imagining the difference, or could changing mixpanel.track to window.mixpanel.track have changed something. And what oh what am I missing here?
推荐答案我认为这是由Mixpanels异步行为引起的.当您调用Submit时,track()指令以非阻塞方式开始执行,即使在对Mixpanel API的track()调用仍在进行时,也允许提交表单.如果发生这种情况,您的表单将在track()调用完成之前提交.
I think this is caused by Mixpanels asynchronous behaviour. When you call submit, the track() instruction starts executing in a non blocking way, allowing to submit the form even when the track() call to the Mixpanel API is still ongoing. If this happens, your form will be submitted before the track() call is completed.
单击链接时会发生同样的事情,并得到解释在这篇文章中.这就是Mixpanel提供 track_links()和 track_forms()方法.这些解决了以下问题,可能对您有帮助.
The same thing is happening when clicking on links and is explained in this post. It's the reason Mixpanel offers the track_links() and track_forms() methods. These solve the problem as follows and may be helpful in your case.
此功能将最多等待300毫秒,以使Mixpanel服务器响应,如果此时尚未响应,它将转到链接,而不确保已跟踪您的事件.要配置此超时,请参阅下面的mixpanel.set_config文档.
This function will wait up to 300 ms for the mixpanel servers to respond, if they have not responded by that time it will head to the link without ensuring that your event has been tracked. To configure this timeout please see the mixpanel.set_config docs below.
更多推荐
Mixpanel跟踪事件间歇性失败
发布评论