Segment.com Integration

Integrating OneSignal as a Destination with Segment

1400

Segment.com is a data platform used by businesses to collect user data from their web and mobile apps. Segment then sends the user data to destinations such as OneSignal to create more effective and personalized marketing campaigns.

📘

We currently only support sending data from Segment to OneSignal.

Coming Soon - Sending OneSignal events to Segment

The current integration with Segment enables the use of OneSignal as a Destination. OneSignal accepts data from any Segment web, mobile, or server source in cloud mode.

Requirements

Step 1. Setup the OneSignal SDKs

Use an existing app that has OneSignal setup OR Create a new one on OneSignal. Below are the detailed app setup instructions.

Please make sure you have your push, email, or SMS subscribers in OneSignal as well.

Step 2. Connect to Segment.com in OneSignal

Within OneSignal Dashboard, navigate to Settings > Analytics and click Active within Segment.com card. Then continue with the setup options.

1768

Step 3. Setup OneSignal Destination in Segment.com

Within Segment.com Dashboard > Destinations you should see OneSignal. If not, add OneSignal as a new destination.

Enable the OneSignal Destination, you should also see your OneSignal API Key and App ID already

2046

If the API key and App Id are not set, navigate to the OneSignal dashboard, select the App, and go to the Settings > Keys & IDs. Copy-Paste the “App ID” and the “API key” into Segment.com.

Multiple Segment.com Sources

If you have multiple sources, you can utilize Segment's Personas > Spaces feature to bind multiple sources to a destination.

Step 4. Sending Data from Segment to OneSignal

OneSignal stores channel-level records: Push/IAM, Email, and SMS. These records must already be created in OneSignal in the following ways:

You must also set the External User Id property in OneSignal to match the userID field sent by Segment.com.

🚧

External User ID is mandatory!!

Records that don't have a Segment User ID <--> OneSignal External User ID mapping will be dropped.

User Traits or Properties

You can aggregate data across every customer touchpoint in Segment and then send these user properties in real-time to OneSignal as Data Tags.

Note: OneSignal can not accept nested objects or arrays as user properties.

Identify - User traits or properties sent using Segment's Identify call are stored as data tags on OneSignal. For example:

OneSignal.setExternalUserId('109768518080488203109')
analytics.identify('109768518080488203109', {
  first_name: 'John',
  last_name: 'Doe'
});
2056

Track - For events and associated properties sent using Segment's Track call, OneSignal will store all the event properties as data tags, but drop the event name while storing the tags. If you want to keep the event names in the data tags, you can append the event name to the properties before sending them to OneSignal. For example:

let timestampInSeconds = Int(NSDate().timeIntervalSince1970).toString()//convert to string since Segment adds decimals to end
//name will be dropped and only properties will be sent to OneSignal as tag "last opened: timestampInSeconds"
analytics.track(
  name: "iOS App Last Opened", 
  properties: ["last opened": timestampInSeconds]
)
2056 1773

Personas Audience and Computed Traits

Persona Audiences automatically show up as a segment in OneSignal.

Computed traits are updated as Data Tags on the OneSignal user (player) records.

Audience

1773

Audiences sent using Segment's Track call will create a OneSignal segment with the Audience Name.

Audiences sent using Segment's Identify call will

  • create a OneSignal segment with the Audience Name and
  • add data tags (if there are additional properties in the Identify call) on all the matching user records.
1773

The Identify and Track calls are automatically sent to OneSignal whenever a user enters or exits the Audience.

Computed Traits
Personas Computed Traits are stored as Data Tags on the OneSignal user (player) records whether passed to OneSignal as an Identify call or a Track call. You can then use these data tags to manually create OneSignal segments and automate your messaging workflows.


FAQ

How can we pass Subscription events?

Subscription events are not currently being sent automatically. This can be done with the OneSignal SDK Subscription Observer Methods. See Subscription Tracking for more details.

Managing Segment’s Reserved and Custom User Properties in OneSignal

  • All the Segment’s user traits are sent to OneSignal as data tags. The number of data tags allowed on OneSignal depends on your OneSignal pricing plan. Tags over the entitled number will be dropped.
  • OneSignal always updates the firstName and the lastName properties for matching users. All other traits are added/updated on a first-come basis. firstName and lastName tags are stored as "first_name" and "last_name".
  • User properties sent to OneSignal with blank/null values are removed from the OneSignal user record. This is done to make sure you are within your data tag limits.
  • OneSignal doesn’t store email and phone properties as these key identifiers are stored as separate player records in OneSignal. To update user traits for these records in OneSignal, you must create a player record with the email address and/or a phone number and map those records with the External_User_ID.