Segment.com Integration

Integrating OneSignal as a Destination with Segment

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.

The current integration with Segment enables the use of OneSignal as a Destination (sending audiences to OneSignal) as well as a Source (sending events to Segment.com). OneSignal accepts data from any Segment web, mobile, or server source in cloud mode.

Requirements

  • A Growth, Professional or Enterprise OneSignal Account.
  • Segment Admin Permissions
  • The OneSignal Mobile SDK and/or Web SDK from which you want to send data. Email or SMS only integrations do not require the SDK.
  • The OneSignal Property: External User Id which maps to the Segment.com userId.

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.

2. Connect to Segment.com in OneSignal

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

2a. Enable Data In Enabling

"Data In" to OneSignal allows you to send audiences to from your Segment.com account to OneSignal. Click Authenticate under the Data In section of the Segment.com setting page in the OneSignal Dashboard.

Once you click Authenticate, a Segment.com webpage will open and you'll be prompted to sign in to your Segment.com account. You'll then be prompted to configure a new data destination from your Segment.com account.

2b. Enable Data Out

Enabling "Data Out" to Segment.com syncs message events generated back to your Segment.com account. These message events are generated from sending messages to your users on the OneSignal platform. More details on what kind of events can be generated, and the properties they are sent with can be found below.

First, you need to add OneSignal as a source from your Segment.com account. You can do that by navigating to the OneSignal Source listing in the Segment Connections Catalogue.

From there, you can add your Segment.com API token on the OneSignal Dashboard. Please navigate Settings > Integrations > Segment in the OneSignal Dashboard to add the Segment API key.

After you set up the API key, please make sure to check your Data Policy settings in Segment.com to determine if you need to send events to Segment's EU Residency Endpoint.

Once all of those settings are done, you can then select which events you want to sync over to your Segment Account depending on which channels you utilize with OneSigna..

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.

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 and you must also set the External ID alias in OneSignal to match the userID field sent by Segment.com.

🚧

External ID is mandatory!!

Records that don't have a Segment User ID <--> OneSignal External 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:

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]
)

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 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 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.


Message Events

Event Kinds

These are the message event kinds that OneSignal sends to Segment

MessageEvent KindEvent Description
Push SentPush notification successfully sent
Push ReceivedPush notification successfully received
Push ClickedPush notification touched on device
In-App Message DisplayedIn-App Message successfully displayed on device
In-App Message ClickedIn-App Message clicked on device
In-App Message Page DisplayedIn-App Message page is displayed
Email SentEmail successfully sent
Email OpenedEmail opened by recipient
Email UnsubscribedEmail unsubscribed by recipient
Email ReceivedEmail received by recipient
Email Reported As SpamEmail reported as spam by recipient
Email HardbouncedEmail returned to sender due to permanent error
Email FailedCould not deliver the email to the recipient’s inbox
SMS SentSMS sent to recipient
SMS DeliveredSMS successfully delivered
SMS FailedSMS failed to send

Event Properties

These are the properties that are present on events sent from OneSignal to Segment.com

PROPERTY NAMEDESCRIPTION
userIdThe external_id associated with the message
anonymousIdThe susbscription_id
messageIdThe identifier of the discrete message
campaign_idThe same value as messageId
message_nameThe message name
message_titleThe message title
message_contentsThe message contents
subscription_typeThe channel the message was sent through
template_idThe message template used
subscription_id.The OneSignal set device/email/sms identifier
device_typeThe device type that received the message
languageThe two character language code of the device
message_typeThe type of message sent, push, in-app, email, SMS

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.