This plugin defines a global plugin.mixpanel
object, which allows access
to Mixpanel's native SDKs. Push notifications are supported and are
explained below. Although the object is in the global scope, it is not
available until after the deviceready
event.
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
plugin.mixpanel.init(mixpanel_token);
}
This guide assumes you are familiar with the Mixpanel native SDKs. For more information visit https://mixpanel.com/help/reference.
- Android
- iOS
cordova plugin add https://github.com/thelinuxkid/cordova-mixpanel
- plugin.mixpanel.init
- plugin.mixpanel.alias
- plugin.mixpanel.identify
- plugin.mixpanel.time_event
- plugin.mixpanel.track
- plugin.mixpanel.flush
- plugin.mixpanel.super_properties
- plugin.mixpanel.distinct_id
- plugin.mixpanel.register
- plugin.mixpanel.unregister
- plugin.mixpanel.register_once
- plugin.mixpanel.clear
- plugin.mixpanel.reset
- plugin.mixpanel.people.distinct_id
- plugin.mixpanel.people.set
- plugin.mixpanel.people.set_once
- plugin.mixpanel.people.increment
- plugin.mixpanel.people.append
- plugin.mixpanel.people.union
- plugin.mixpanel.people.unset
- plugin.mixpanel.people.track_charge
- plugin.mixpanel.people.clear_charges
- plugin.mixpanel.people.delete_user
- plugin.mixpanel.people.init_push_handling
- plugin.mixpanel.people.set_push_reg_id
- plugin.mixpanel.people.clear_push_reg_id
- plugin.mixpanel.people.add_push_token
Initializes the library. Calls MixpanelAPI.getInstance(this, mixpanel_token)
on Android and [Mixpanel sharedInstanceWithToken:mixpanel_token]
on iOS.
- Android
- iOS
Calls alias
. On iOS, calls createAlias
.
- Android
- iOS
Calls identify
.
Also calls people.identify
.
- Android
- iOS
Calls timeEvent
.
- Android
- iOS
Calls track
.
- Android
- iOS
Calls flush
.
- Android
- iOS
Returns the user's super properties.
- Android
- iOS
Returns the user's distinct ID.
- It's the same as
plugin.mixpanel.people.distinct_id
.
- Android
- iOS
Calls registerSuperProperties
.
- Android
- iOS
Calls unregisterSuperProperty
.
- Android
- iOS
Calls registerSuperPropertiesOnce
.
- Android
- iOS
Calls clearSuperProperties
.
- Android
- iOS
Calls reset
.
- Android
- iOS
Returns the user's distinct ID using the People class.
- It's the same as
plugin.mixpanel.distinct_id
.
- Android
- iOS
Calls people.set
.
- Android
- iOS
Calls people.setOnce
.
- Android
- iOS
Calls people.increment
.
- Android
- iOS
Calls people.append
.
- Android
- iOS
Calls people.union
.
- Android
- iOS
Calls people.unset
.
- This method is missing in the iOS SDK.
- Android
Calls people.trackCharge
.
- Android
- iOS
Calls people.clearCharges
.
- Android
- iOS
Calls people.deleteUser
.
- Android
- iOS
Calls people.initPushHandling
.
- Android
Calls people.setPushRegistrationId
.
- Android
Calls people.clearPushRegistrationId
.
- Android
Calls people.addPushToken
.
- iOS
This plugin can be used in conjunction with PushPlugin to receive push notifications. Follow the PushPlugin README to setup the notifications, then, come back here to finish the setup for Mixpanel. Make sure to install https://github.com/thelinuxkid/PushPlugin.git and NOT https://github.com/phonegap-build/PushPlugin.git, at least until the pull request is merged.
Mixpanel stores the actual notification message under the key
mp_message
. So, it must explicitly be set in the register
method::
pushNotification.register(
successHandler,
errorHandler,
{
"senderID":"replace_with_sender_id",
"ecb":"onNotification",
"messageKey": "mp_message"
});
Then, in the ebc
, pass the reg ID to Mixpanel::
case 'registered':
if (e.regid.length > 0) {
plugin.mixpanel.people.set_push_reg_id(e.regid);
}
Pass the push token to Mixpanel in the tokenHandler function. Call flush
to ensure the token is sent right away::
function tokenHandler (result) {
plugin.mixpanel.people.add_push_token(result);
plugin.mixpanel.flush();
}