If you would like to employ the help of a third-party Cordova plugin, see the Cordova-Mixpanel plugin.
Host Mixpanel Locally
It is necessary to host Mixpanel's library locally. Since version 2.1.0 of Cordova, all domains are whitelisted by default.
Load the Mixpanel library from your local device with the following code:
Note the only difference between the snippet above and the typical minified snippet is the file location for the Mixpanel library.
Setting Up Push Notifications
Mixpanel's methods for initializing push notifications are specific to our mobile SDK's, and will grab the device token and append it to the list properties $ios_device()or $android_device.
To replicate this logic either grab and set these properties from your backend, or include client-side logic to add this property through a mixpanel.people.append() call. Without the device tokens appended as a list property, Mixpanel won't be able to target users for push notifications.
Once you have the device tokens correctly uploaded, you'll need to generate your iOS push cert and GCM API key.
At this point you should be able to send out iOS push notifications from your Mixpanel Notifications dashboard. Android may be a little more complicated, as Mixpanel's Webapp generates pushes with JSON keys that are specific to the Mixpanel GCM receiver.
Mind the Queue
Tracking data on mobile devices presents unique challenges with regard to connectivity.
As a result, it is important that you build your own queueing system to store events that are triggered by users when they are not connected to the internet.
With this in mind, the custom queuing functionality that you'd need to set-up on your end should account for when an end-user does not have an active connection on the phone.
So events intended to be sent when the device does not have connection should be added to a local queue to be sent in the future.
Your queuing system should periodically check to see if a connection is established, before emptying the queue if and when there is a connection.
In regards to the time associated with these queued events, you will want to make sure you are time-stamping them correctly as you queue them. If they arrive at Mixpanel's /track API endpoints out of order, they will be stored under the correct time.
Note that it is best practice to limit the number of calls at 40 per batch to ensure all calls are successful (as in Mixpanel's iOS Library).