Segment Rules

Segments can be created using rules. These rules are composed of three parts:

  • ruleId:

    The name of the rule e.g. "sessionCounts", "device"

  • operator:

    The operation that should be performed on the value. Differs from rule to rule

  • value:

    The actual value to apply to the rule

The complete list of rules and their allowed operators and values is as follows

duration

The total period the users device has had your app open (in seconds)

Allowed operators: greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual

Value: Integer type

example:

{
    "ruleId": "duration",
    "operator": "greaterThanOrEqual",
    "value": 4
}

device

Users operating device

Allowed operators: is

Value: Array of Strings. Allowed array strings are "IOS" and "ANDROID"

example:

{
    "ruleId": "device",
    "operator": "is",
    "value": ["IOS"]
}

firstSession

First communication with users device

Allowed operators: between, before, after

Value: Object with keys of date if operator is before or after, to and from if operator is between. All values must be strings of ISO 8601 Date and Time format

examples:

{
    "ruleId": "firstSession",
    "operator": "before",
    "value": {
      "date": "2020-07-11T15:32:46+00:00"
    }
}
{
    "ruleId": "firstSession",
    "operator": "between",
    "value": {
      "from": "2020-07-11T15:32:46Z",
      "to": "2020-07-21T16:00:46Z"
    }
}

lastSession

Most recent communication with users device

Allowed operators: between, before, after

Value: Object with keys of date if operator is before or after, to and from if operator is between. All values must be strings of ISO 8601 Date and Time format

examples:

{
    "ruleId": "lastSession",
    "operator": "before",
    "value": {
      "date": "2020-07-11T15:32:46+00:00"
    }
}
{
    "ruleId": "lastSession",
    "operator": "between",
    "value": {
      "from": "2020-07-11T15:32:46Z",
      "to": "2020-07-21T16:00:46Z"
    }
}

sessionCounts

Number of times user has opened your app

Allowed operators: greaterThanOrEqual, lessThanOrEqual, is

Value: Integer type

examples:

{
    "ruleId": "sessionCounts",
    "operator": "lessThanOrEqual",
    "value": 12
}

deviceLanguage

Current device language used by users

Allowed operators: is, isNot

Value: ISO-639-1 language code string value

examples:

{
    "ruleId": "deviceLanguage",
    "operator": "is",
    "value": "en"
}
{
    "ruleId": "deviceLanguage",
    "operator": "isNot",
    "value": "es"
}

deviceModels

Match specific users Device Models

Allowed operators: in, notIn

Value: Array of Strings. Each array entry is a device model identifier that you want to match.

examples:

{
    "ruleId": "deviceModels",
    "operator": "in",
    "value": [
      "Samsung S20",
      "iPhone 11"
    ]
}

location

Most recent users location

Allowed operators: inside, outside

Value: Object with keys latitude, longitude and radius. Values for radius are provided in meters. All are required.

examples:
Will search for all users that are located within 5 km radius from center of London.

{
    "ruleId": "location",
    "operator": "inside",
    "value": {
        "latitude": 51.509865,
        "longitude": -0.118092,
        "radius": 5000
    }
}

Will search for all users that are located outside the 34 km radius from center of New York. Essentially this is inversion of the inside operator.

{
    "ruleId": "location",
    "operator": "outside",
    "value": {
        "latitude": 40.7128,
        "longitude": -74.0060,
        "radius": 34000
    }
}

deviceIds

Match specific users Device Ids

Allowed operators: in, notIn

Value: Array of Strings. Each array entry is a device ID that you want to match.

examples:

{
    "ruleId": "deviceIds",
    "operator": "in",
    "value": [
      "d750G-n29oMnW8",
      "f2GsZmedWw0"
    ]
}

NOTE: dynamism will not work with this option. Do not include dynamism in the api request

subscriberIds

Match specific users Ids

Allowed operators: in, notIn

Value: Array of Strings. Each array entry is a subscriber ID (UUIDv4) that you want to match.

examples:

{
    "ruleId": "subscriberIds",
    "operator": "in",
    "value": [
      "e412c0a1-9432-4a49-86c1-b1b504e4c114",
      "808ba62c-3bb7-4eb5-bce9-3ebab28c8e19"
    ]
}

NOTE: dynamism will not work with this option. Do not include dynamism in the api request

appVersion

Match specific App Versions users have installed

Allowed operators: in, notIn

Value: Array of Strings.

examples:

{
    "ruleId": "appVersion",
    "operator": "in",
    "value": ["3.4.16-beta", "3.4.15-golden-release"]
}

tags

Match specific Tags that users are associated with

Allowed operators: in, notIn

Value: Array of Strings.

examples:

{
    "ruleId": "tags",
    "operator": "in",
    "value": ["premium", "loyal"]
}

customerIds

Match specific customer identifiers for your users

Allowed operators: in, notIn

Value: Array of Strings. Each array entry is a customer ID that you want to match.

examples:

{
    "ruleId": "customerIds",
    "operator": "in",
    "value": [
      "sugar-crm-customer-id-123",
      "my-external-system-user-identifier",
      "loyal-customers-group-name-in-my-external-crm"
    ]
}

NOTE: dynamism will not work with this option. Do not include dynamism in the api request

locationPermission

Match users that have opted in to allow precise location data to be accessed

Allowed operators: is

Value: Boolean type

examples:

{
    "ruleId": "locationPermission",
    "operator": "is",
    "value": true
}

notificationPermission

Match users that have opted in to allow notifications to be sent

Allowed operators: is

Value: Boolean type

examples:

{
    "ruleId": "notificationPermission",
    "operator": "is",
    "value": true
}

countryCode

Match specific country code(s) for your users

Allowed operators: in, notIn

Value: Array of Strings. Each array entry is a country code (ISO 3166-1 alpha-2 standard) that you want to match.

examples:

{
    "ruleId": "countryCode",
    "operator": "in",
    "value": [
      "GB",
      "US",
      "LT"
    ]
}

notificationPushStatus

Match specific pushed notification, and it's reached delivery status(es) for your users

Allowed operators: in, notIn

Value: Object with keys "notificationId" and "status". Where "notificationId" is a valid Notification ID and "status" is an array of strings with minimum 1 entry, each entry being one of following supported values:

  • pending
  • received
  • downloaded
  • download_failed
  • opened
  • viewed
  • link_opened
  • push_failed

Operator "notIn" will perform an inverted match for provided status(es) with notification ID provided.

examples:

{
    "ruleId": "notificationPushStatus",
    "operator": "in",
    "value": {
      "notificationId": "3144764e-577e-4933-b961-54bba80a1bf5",
      "status": ["downloaded", "link_opened"]
    }
}