Segments

Cohorts or Groups of users based on data collected and sent to OneSignal.

A segment gives you the ability to group and target users with more personalized and engaging messages. You can create specific audiences based on multiple data filters, such as activity, country, language, Data Tags, etc.

Segments are dynamic, which means they update automatically and continuously once created. As users interact with your app or website, they may be added to or removed from segments without any additional setup or tracking on your end, depending on the filters used.

📘

Segments Count Opted-In Subscriptions

The counts you see are the number of subscribed or opted-in Push, SMS, and Email subscriptions.

Segments used for Journeys and In-app Messages will include the users and opted-out subscriptions.

There is currently not a way to get the counts of unsubscribed subscriptions with segments. Use the Export CSV of Players API to get this data.

Create Segments

Segments can be created from the dashboard, from the Create segment API endpoint, or by uploading a CSV file.

Creating Segments Through the Dashboard

In Audience > Segments select New Segment.

New Segment

Add Filters

Combine available filters to create a segment. Not all platforms support each filter type, and not all filters have the same options.

For example, select the Last Session filter for the last time a user visited your app or website.

Segment Filters

Set this to be "greater than" 7 days. This will tell us how many users have not returned to the site or app in over 7 days.

Segment Filters

Segment filters in the dashboard editor

FilterDescription
FIRST SESSIONMobile - The first date/time the user opened the app with OneSignal SDK active and valid network connection.
Web Push - The first date/time the user subscribed to your site.
LAST SESSIONThe most recent date/time the user's device communicated with OneSignal servers. Updated when device opens the app on mobile or subscriber returns to the site and attempted to update again upon leaving the app / website. Does not update when app is in the background.
SESSION COUNTMobile- The number of times the user's device has opened your app.
Web Push - The number of times the user visited your website after not having the website open previously.
USAGE DURATIONThe total number of seconds the subscription has had your app open.
LANGUAGEUser's preferred language. See Language & Localization for possible codes.
APP VERSIONVersion of your app gathered from Android Studio versionCode in your App build.gradle and iOS uses Identity Version or CFBundleShortVersionString in Xcode.
DEVICE TYPEDevice operating system: Google Android, Huawei Android, iOS, Windows Phone, Chrome, Firefox, Safari, or Email
USER TAGRequires Data - Tags you have added to the user. See Data & Tags for more details. User Tags that exist on test users will automatically populate in the segment editor dropdown.
LOCATIONRequires Data - Radius in meters from a particular geocoordinate (lat, long).
ROOTEDAndroid - whether devices is rooted.
COUNTRYThe ISO 3166-2 country code of the IP address detected on the user's device the last time it communicated with OneSignal servers.
TEST USERSIncludes all test users that you have set up as a Test User.

Creating Segments through the API

This API requires a paid plan.

The Create Segment method is used when you want your server to create a segment. Just like creating a segment from the dashboard, you can pass in filters with multiple "AND" or ”OR" operator's.

FilterDescription
first_sessionMobile: First date/time the user opened the app with an active OneSignal SDK and valid network connection
Web: First date/time the user subscribed to your site
last_sessionMost recent date/time the user's device communicated with OneSignal servers. This is updated when a device opens the app on mobile or user returns to the site, and it attempts to update again upon leaving the app / website. This does not update when app is in the background.
session_countMobile: Number of times the user's device has opened your app
Web: Number of times the user visited your website after not having the website open previously
session_timeTotal number of seconds the user has had your app open
languageUser's preferred language (see Language & Localization for codes)
app_versionVersion of your app gathered from Android Studio versionCode in app build.gradle and iOS Identity Version or CFBundleShortVersionString in Xcode
amount_spent
bought_sku
tagRequires data: Data you have added to the user (see Data Tags for more details)

(Data Tags for test users will automatically populate in the segment editor dropdown)
locationRequires data: Radius in meters from a particular geocoordinate (lat, long)
countryISO 3166-2 country code of the IP address detected on the user's device the last time it communicated with OneSignal servers

Delete Segments

Delete Segments through the Dashboard

In Audience > Segments, click the option button (three dots) to the left of the segment you want to delete. In the pop-up menu, select Delete. Deleting segments cannot be undone, so be certain that you no longer need the segment before deleting it.

Delete Segments using the API

The Delete segment method only deletes the segment itself, not the users within the segment. To permanently delete users within a segment, see Delete Users.

{
  "name": "Segment 2",
  "filters": [
    {"field": "session_count", "relation": ">", "value": "1"},
    {"operator": "AND"},
    {"field": "tag", "relation": "!=", "key": "tag_key", "value": "1"},
    {"operator": "OR"},
    {"field": "last_session", "relation": "<", "hours_ago": "30"}
  ]
}

//Another Example

{
  "name": "iOS, Android, Web", 
  "filters": [
    {"field": "device_type", "relation": "=", "value": "iOS"},
    {"operator": "OR"},
    {"field": "device_type", "relation": "=", "value": "Android"},
    {"operator": "OR"},
    {"field": "device_type", "relation": "=", "value": "Web Push (Browser)"}
  ]
}


Filter AND Clauses

After adding your first filter, the Add filter button will create an "AND clause" which requires all users to fit into all filters combined with "AND clauses".

Under "Last Session" select Add filter and select Last Session again.

Set this to be "less than" 264 hours.

When a user has not visited the site in over 7 days they will enter into this segment AND after 264 hours (11 days) they will be moved out of this segment.

Segment Filters

Filter OR Clauses

To combine multiple filters that do not depend on each other, click Add Or to separate groups of filters.

Select Add Or and select First Session "greater than" 3 days.

Now, the segment contains all users that "First Subscribed" over 3 days OR users that have not been back to the site in over exactly 10 days.

Name the segment something memorable like 7 Days Inactive Or Over 3 Days New and select Create Segment.

Segment Filters

Exclude segments

Choose which segment should not receive certain message campaigns or participate in Journeys. Common use cases for excluding segments is to avoid messaging users with irrelevant messaging, enforce messaging preferences, and support a broader strategy of managing message volumes. Excluding audiences will typically become more prevalent as you scale your messaging strategy when multiple campaigns, journeys, product and transactional messages are deployed.


Segment Options

Select the Options button next to the segment to do the following:

Segment Options

View users

Navigates to the Audience > Subscriptions page to view the user subscriptions contained in the segment.

Edit

Opens the segment editor. Same as clicking the segment directly.

Pause & Resume

Depending on your plan type you can pause segments to create more. If a segment is paused when trying to target it, the notification will fail.

Set as Default

The OneSignal Dashboard defaults to the "Subscribed Users" segment when sending messages. This can be changed by setting a "default segment".

A "default segment" will be the first segment selected when creating a message within the OneSignal Dashboard. This is to help both quickly target certain segments used frequently and help prevent mistakes if the segment is not changed before sending the message.

Duplicate

Creates a copy of the segment filters.

Exclude Segments

This an option that lets you choose which segment should not receive certain message campaigns or participate in Journeys.

Exclude Segments is an option that lets you choose which segment should not receive certain message campaigns or participate in Journeys. Common use cases for excluding segments is to enact messaging preferences– such as certain category topics that your Customers have subscribed to, support a broader and more comprehensive strategy of managing message volumes as well as adding priority logic to important campaigns or journey workflows. This tool will typically become more prevalent as you scale your engagement program when multiple campaigns, journeys, product and transactional messages are deployed.



FAQ

Segments Count Opted-In Subscriptions

The counts you see when editing a segment or viewing the list in the segments screen are the number of subscribed or opted-in push, SMS, and email subscriptions.

Segments used for Journeys and in-app messages will include the users and opted-out subscriptions.

There is currently not a way to get the counts of unsubscribed subscriptions with segments. Use the Export CSV of Players API to get this data.

Are segment counts accurate?

Once you reach over 80,000 Total Users, segment counts begin to be estimated in order to keep the dashboard running quickly and smoothly. To get the most accurate numbers, see the Delivery stats for the message sent to that segment.

What kind of in-app purchases are tracked and how can I import historical in-app purchases?

The OneSignal mobile SDKs will automatically track "Consumable" in-app purchases made while the OneSignal SDK is active in the app. Subscription based in-app purchases are not tracked.

To update a device's previously bought in-app purchases before the OneSignal SDK was added, use the Update user API to update the purchases parameter.


What’s Next