OneSignal Help & Documentation

Welcome to the OneSignal New IA developer hub. You'll find comprehensive guides and documentation to help you start working with OneSignal New IA as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    Discussions

Mixpanel

Integrating OneSignal with Mixpanel

Mixpanel and OneSignal have joined forces to provide:

Feature

Details

Personalized messaging

Boost engagement with more contextualized messaging from OneSignal, triggered when users enter or exit Mixpanel cohorts

Real-time insights

Gain a holistic view of customers by combining Mixpanel in-product user actions and OneSignal message engagement metrics

Data-driven campaigns

Leverage product-level user insights for re-engaging campaigns through OneSignal

🚧

Requirements

A Paid OneSignal Account is required for this integration.

Moving Current Mixpanel Subscriptions to OneSignal

After following the below steps, your user data will be synced with OneSignal as follows:

User Type

Details

Push Subscribers

Automatically and silently (not prompted again) moved into OneSignal upon updating the mobile app or returning to the website. New Users can subscribe through Prompting.

Email Subscribers

Emails can be Imported in a one-time step to immediately message your userbase and synced overtime using our API. Details in Email Quickstart.

Make sure you have added the OneSignal Mobile SDK and/or Web SDK and have started collecting Subscribers.

Step 1. Turn on Integration

Navigate to your onesignal.com Dashboard > Settings > Analytics and Activate Mixpanel

Step 2. Add Mixpanel Token in OneSignal dashboard

You can find your Mixpanel token under "Access Keys" in your "Project Token". See Mixpanel's "Find Project Token" guide.

If you are using Mixpanel EU servers, select Send events exclusively to Mixpanel EU servers.

OneSignal messaging events will automatically show up in the activity feed of a user in Mixpanel.

Mixpanel to OneSignal

Step 3. Add OneSignal to Mixpanel Integrations

Get your OneSignal App ID and REST API Key

In your mixpanel.com dashboard > Data Management > Integrations. Select "OneSignal" and press Connect.

With your OneSignal App ID & REST API Keys input them into the Mixpanel fields and press Continue.

Step 4. Send Mixpanel the OneSignal User ID

Now that the OneSignal and Mixpanel SDKs are in the app/site, you can leverage the OneSignal User Status Data methods to get the player_id which is the OneSignal Device ID and send it to Mixpanel as a user attribute.

Through the Mixpanel API, set this OneSignal User ID $onesignal_user_id to the people property like so:

//Set the OneSignal Push player id record
OneSignal.push(function() {
  OneSignal.getUserId(function (userId) {
    console.log("OneSignal User ID:", userId);
    mixpanel.people.set({
      $onesignal_user_id: userId
    });
  });
});
//OneSignal method to get the player id (user id) Android SDK 3.15-
OSPermissionSubscriptionState status = OneSignal.getPermissionSubscriptionState();
String userId = status.getSubscriptionStatus().getUserId();//String: the OS Player Id or null if device has not registered with OS Servers
mixpanel.getPeople().set("$onesignal_user_id", userId);

//OneSignal method to get the player id (user id) Android SDK 4.0+
OSDeviceState device = OneSignal.getDeviceState();
String userId = device.getUserId();//String: the OS Player Id or null if device has not registered with OS Servers
mixpanel.getPeople().set("$onesignal_user_id", userId);
// If using OneSignal iOS SDK 2.16-
let status: OSPermissionSubscriptionState = OneSignal.getPermissionSubscriptionState()
if let userId = status.subscriptionStatus.userId {
    Mixpanel.mainInstance().people.set(properties: ["$onesignal_user_id":userId])
}

// If using OneSignal iOS SDK 3.0.0+
let deviceState = OneSignal.getDeviceState()
if let userId = deviceState?.userId {
    Mixpanel.mainInstance().people.set(properties: ["$onesignal_user_id":userId])
}

🚧

Highly Important

User profiles without this user property will not export to OneSignal - it is a requirement for user matching.

Step 5. Export Mixpanel Cohorts to OneSignal

As you start sending Mixpanel the $onesignal_user_id you will see a new User Property in Mixpanel called OneSignal User Id. You can use is set to filter all devices currently associated with the OneSignal Device Record.

In Mixpanel Users > Cohorts select the 3-dot option next to the cohort you want to send push.

Select Export to... > OneSignal

Under "Export Type" you have 2 options:

  1. "One-time export" will send OneSignal the current user data. Best if sending one message only to the current users.
  2. "Dynamic Sync" is where Mixpanel will send OneSignal the updated cohort data around every 15 minutes. Best if sending recurring messages to updated user list.

Select the option and press Begin Sync.

  1. The exported Mixpanel Cohorts will show in the onesignal.com dashboard Audience > Segments as a new segment and will become available as a segment filter for further customization.

Why am I not seeing all my cohort users inside the OneSignal segment?

There are generally 3 reasons why your Mixpanel Cohort Users will not all show up inside a OneSignal Segment:

  1. the OneSignal player_id must be synced. Make sure you to add the $onesignal_user_id to the Mixpanel user record through our SDKs. See Step 4.
  2. the device must be subscribed to push notifications. Device records with an active $onesignal_user_id in Mixpanel may not be subscribed to push notifications, any device not subscribed to push will not be inside the OneSignal Segment.
  3. Dynamic vs One-time export. Syncing occurs every 15 minutes for Dynamic exports, you may need to wait to see all the data sync over.

You can verify this in the Mixpanel Cohort filtering All Users where OneSignal User Id is set.

🚧

Cohort - Segment User Discrepancies

Users within Mixpanel Cohorts sent to OneSignal must satisfy 2 requirements:

  1. the $onesignal_user_id property must be set on the device. See step 4.
  2. the device must be subscribed to push. OneSignal Segments only contain subscribed users.

OneSignal will also automatically syncs the $first_name and $last_name user info from Mixpanel user records to our Data Tags if they are present. This is helpful for Message Personalization.

For example:

OneSignal.push(function(){
  OneSignal.getUserId(function (userId) {
    mixpanel.people.set({
      $onesignal_user_id: userId,
      $first_name: 'Billy',
      $last_name: 'Bob'
    });
  });
});

Step 6. Tracking Message Data in Mixpanel

🚧

Email Limitations

Currently OneSignal only tracks Push and In-App Message Events in Mixpanel.

Email Events, like sent, received, and clicked will be available in a future update.

In Mixpanel, OneSignal Push Notification and In-App Message events will appear in activity feed like:

  • Message Sent
  • App Opened from Push (clicked event)

Those have properties
time - the time the event happened
delivery_id - OneSignal notification ID
campaign_id - the heading from the notification or title from the IAM
$source - this is always onesignal
message_type - push/email/in-app

Cohort Events

You can use the following events to create cohorts in Mixpanel:

  • Notification clicked

  • Notification sent

  • Notification received (this corresponds to confirmed deliveries, which is turned off right now)

  • IAM Displayed

  • IAM Clicked

Those have properties
time - the time the event happened
delivery_id - OneSignal notification ID
campaign_id - the heading from the notification or title from the IAM
$source - this is always onesignal.

Example Cohorts

Did not click a push or in-app message

With this type of Cohort you can track devices that may not have received your push or in-app message to send them an email or sms text.

Checking the users that did get a Message Sent greater than 1 time in the Last Day, where Message Type equals to push.
AND
Users that Did Not have the App Opened from Push (works on web as well) in the Last day.

Were Shown a Specific Message in the Past Day

Using Message Sent at least 1 time, in the Last 7 days where Message Type equals in-app and Message equals [name of the message]

In this cast the [name of the message] is pulled from:

  • Push Notification Title
  • In-App Message Name

Updated about 17 hours ago



Mixpanel


Integrating OneSignal with Mixpanel

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.