Reputation: 8572
similar to: Does Mixpanel Analytics for Android work when offline?
On the Javascript API, does the event and user tracking are keep safe when the visitor is offline?
I ask because our application is sometimes used on mobile and we need to track this offline events still.
Upvotes: 4
Views: 2015
Reputation: 3493
Mixpanel does not support tracking while offline, but there's no reason why you can't implement it yourself. At the end of the day, Mixpanel JS library is a JavaScript wrapper over the HTTP API.
You can write your own JavaScript library that uses the Mixpanel HTTP API. You can learn about how to do this for an Ionic/Cordova app here - although the blog post is targetted at tracking for offline Cordova apps, it demonstrates the concept of offline-resilient tracking for Mixpanel using JavaScript.
Upvotes: 0
Reputation: 11385
It doesn't out of the box, as raylu pointed in the original source code. But if you also look at the source code and the documentation for the REST API, you can pass in time
as an argument to track
, which allows you to make sure that the timestamps are correct (as an improvement on henry's answer).
If you look for MixpanelLib.prototype.track
in the JS, you can see that it doesn't change time, and if you look at the REST API documentation, they specifically say:
time is the time at which the event occured, it must be a unix timestamp, requests will be rejected that are 5 days older than codesent time - this is done for security reasons as your token is public generally. Format is seconds since 1970, GMT time zone. If you'd like to import data, you can through a special API for any event.
Upvotes: 1
Reputation: 1718
On html5 devices and browsers Localytics writes all event data to Persistent Storage and uploads them w/ the correct timestamp when connection is available.
Although Mixpanel doesn't work like this out of the box you could use the same approach and check their callback value to determine when to delete the events. The timestamps won't be correct but you will get all of your data.
Feel free to check our source (linked in the doc below) to see how we do it: http://www.localytics.com/docs/html5-integration/
-- Henry
Upvotes: 1
Reputation: 2814
No, it does not. If you look at the uncompressed JS, events are not queued up and there are no retries on failure. The callback is passed a 0 in the event of failure, though, so you can use this to implement your own retry if you want.
Upvotes: 4