OneSignal is a popular service that helps you drive customer engagement with multi-channel messaging across web and mobile push notifications, in-app messages, SMS, and email subscribers.
RudderStack supports OneSignal as a destination where you can send your event data seamlessly.
Getting started
Before configuring OneSignal as a destination in RudderStack, verify if the source platform is supported by OneSignal by referring to the table below:
Connection Mode | Web | Mobile | Server |
---|---|---|---|
Device mode | - | - | - |
Cloud mode | Supported | Supported | Supported |
Once you have confirmed that the source platform supports sending events to OneSignal, follow these steps:
- From your RudderStack dashboard, add a source. Then, from the list of destinations, select OneSignal.
- Assign a name to the destination and click Continue.
Connection settings
To successfully configure OneSignal as a destination, you will need to configure the following settings:
- App Id: Enter your OneSignal App ID.
- Toggle on to add a device using email: Enable this setting to add a new device to your OneSignal app using the email.
- Toggle on to add a device using phone number: Enable this setting to add a new device to your OneSignal app using the phone number.
- Toggle on to concatenate event name with properties: Enable this setting to concatenate the event names with properties. For example, if
add_to_cart
is an event andbrand
is a property, the event will be sent asadd_to_cart_brand
tag. - Allowed Property List: Enter the properties you want to add as the device tags, if present in the payload.
track
and group
calls.Identify
You can make an identify
call to add a new device to your OneSignal App. However, if a device is already registered with the specified identifier, then it will update the existing device's records.
A sample identify
call is shown below:
rudderanalytics.identify('1hKOmRA4el9Zt1WSfVJIVo4GRlm', { firstName: 'Alex', lastName: 'Keener', email: "alex@example.com"}, { externalId: [ { type: "playerId", id: "Df344sdFgdDsS4" } ], integrations: { oneSignal: { deviceType: "6", identifier: "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d" } });
In the above snippet, the playerId
is the unique ID for a device. If playerId
is provided in externalId
, the device having that playerId
will be updated. The externalId
is case-sensitive; for correct mapping, it should present in the exact format as seen above.
anonymousId
as a tag with the key as anonymousId
along with the corresponding value.RudderStack maps the following browser and mobile device types by default:
deviceTypeMapping = { android: 1, ios: 0, chrome: 5, safari: 7, firefox: 8}
You can override the above-mentioned device type mappings or set any other device type by providing the deviceType
and identifier
in the integrations
object, as shown:
"integrations": { "one_signal": { "deviceType": "Sample device", "identifier": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d" }}
- For browser, RudderStack checks the browser name in
deviceTypeMapping
as mentioned in the above code snippet and maps it to OneSignal'sdevice_type
property. It also sets theanonymousId
as theidentifier
depending on the browser name. - For iOS and Android, RudderStack collects the
context.device.type
field and maps it to OneSignal'sdevice_type
property. It also sets thecontext.device.token
/context.device.id
as theidentifier
.
device.token
for push notifications.- For email and SMS, enable the Toggle on to add a device using email and Toggle on to add a device using phone number settings in the RudderStack dashboard and send the relevant data (
email
orphone
) in the event payload.
Property mapping
The following table details the mappings between the optional RudderStack and OneSignal properties:
RudderStack property | OneSignal property |
---|---|
context.device.model | device_model |
context.os.version | device_os |
context.timezone | timezone |
userId | external_user_id |
context.locale | language |
traits.createdAt /context.traits.createdAt /timestamp /originalTimestamp | created_at /last_active |
traits.country /context.traits.country /traits.address.country /context.traits.address.country | country |
integrations.one_signal.deviceType | device_type |
integrations.one_signal.identifier | identifier |
string
key-value pairs from traits
are mapped inside the tags
object as it is.Track
You can use the track
to update an existing device's tags in your OneSignal apps using the external_user_id
parameter. All devices containing the particular external_user_id
are updated simultaneously.
While updating a device tag, you can delete any key inside a tag by providing the key value as an empty string.
A sample track
call is shown below:
rudderanalytics.track('Add to cart', { purchased_item: "Shirt", brand: "Zara"});
Property mapping
The following table details the mappings between RudderStack and OneSignal properties:
RudderStack property | OneSignal property | Presence |
---|---|---|
userId | external_user_id | Required |
tags
object if they are present in the payload. However, note that the key-value pair should be of the String data type only.Group
You can use the group
call to group the devices with the device tags having the same groupId
.
A sample group
call is as shown:
rudderanalytics.group('1hKOmRA4el9Zt1WSfVJIVo4GRlm', { name: "Apple Inc.", location: "USA",});
Property mapping
The following table details the mappings between RudderStack and OneSignal properties:
RudderStack property | OneSignal property | Presence |
---|---|---|
groupId | groupId | Required |
tags
object if they are present in the payload. However, note that the key-value pair should be of the String data type only.FAQ
Where can I find the OneSignal App ID?
To get your OneSignal App ID, follow these steps:
- Log into your OneSignal dashboard.
- Go to your app's Settings > Keys & IDs.
- You will find the OneSignal App ID, as shown:
Contact us
For more information on the topics covered on this page, email us or start a conversation in our Slack community.