Does Mixpanel Analytics for Javascript work offline?

similar to: Does Mixpanel Analytics for Android work offline?

Does the Javascript API track events and user tracking when a visitor is disconnected?

I ask because our application is sometimes used on mobile devices, and we need to track this offline events.

+4
source share
4 answers

No, it is not. If you look at uncompressed JS , events are not queued, and there are no attempts at failures. the callback is passed 0 in case of failure, so you can use this to implement your own attempt if you want.

+4
source

On devices and browsers, html5 Localitics records all event data in Persistent Storage and loads it with the correct timestamp when connected.

Although Mixpanel doesn't work that way, you can use the same approach and check their callback value to determine when to delete events. Timestamps will not be correct, but you will receive all your data.

Remember to check our source (linked in the document below) to find out how we do this: http://www.localytics.com/docs/html5-integration/

- Henry

+1
source

This is not out of the box, as raylu indicated in the source code . But if you also look at the source code and documentation for the REST API , you can pass time as an argument to track , which allows you to make sure the timestamps are correct (as an improvement to Henry's answer).

If you look for MixpanelLib.prototype.track in JS, you can see that it does not change the time, and if you look at the REST API documentation, they will say in particular:

time is the time at which the event occurred, it must be a unix timestamp, requests will be rejected that are 5 days older than the time specified in the code - this is done for security reasons, since your token is publicly available. The format is seconds since 1970, the time zone is GMT. If you want to import data, you can use a special API for any event.

+1
source

Mixpanel does not support offline tracking, but there is no reason why you cannot implement it yourself. At the end of the day, the Mixpanel JS library is a JavaScript wrapper using the HTTP API.

You can write your own JavaScript library that uses the Mixpanel HTTP API . You can learn how to do this for the Ionic / Cordova application here - although the blog post is configured to track Cordoba’s offline applications, it demonstrates the concept of offline tracking for Mixpanel using JavaScript.

0
source

All Articles