Targeting your audience using Attributes

Target Attributes using the dashboard or API.

Text, Number, and Date Attributes are targeted directly. You specify the Attribute, an operator, and a value to evaluate against. For JSON Attributes, you target specific properties within the JSON schema, not the object as a whole.

 Warning

To target users based on a unique user ID or other external identifier, do not use Custom Attributes. Instead, target Named UserA customer-provided identifier used for mapping multiple devices and channels to a specific individual..

Targeting in the dashboard

To target Attributes in the dashboard, create a SegmentA grouping of audience members selected by unique or shared identifiers. Multiple identifiers can be combined within a Segment. and add each Attribute as a condition. In the image below, the Segment includes a Text Attribute targeting users whose favorite food is lasagna. The Attribute name is “Favorite Food”, the operator is Equals, and the value is lasagna.

The example also shows the use of the boolean AND. Overall, the Segment dictates sending to audience members who have the TagMetadata that you can associate with channels or Named Users for audience segmentation. Generally, they are descriptive terms indicating user preferences or other categorizations, e.g., wine_enthusiast or weather_alerts_los_angeles. Tags are case-sensitive. airship and also have the Text Attribute “Favorite Food” that equals lasagna. If a user does not meet both conditions, they will not be included in the message audience.


For JSON Attributes, you target one or more properties in its schema for evaluation. For multiple properties, set boolean logic to determine whether any or all evaluations must be true for the whole condition to be true.

After selecting a JSON Attribute:

  1. Select Configure.
  2. Under Evaluations, choose from the Select a source menu:
    OptionDescription
    <alias>An alternate name defined for a property. The Attribute's schema will appear with the aliased property's line selected.
    Select from schemaThe Attribute's schema will appear. Select a property's line, then its path will appear to the right of the menu.
  3. (For string and number properties) Select an operator and enter a value.
  4. (For boolean properties) Select Is true or Is false.
  5. (Optional for arrays in the path) Select First or Last to specify the first or last item in the array. Defaults to Any.
  6. Select the check mark to add the property.
  7. Select Add another for more properties.
  8. (For multiple properties) Select AND or OR to determine how to evaluate multiple properties within the condition:
    • AND = all criteria must be met
    • OR = any criteria must be met
  9. Select Done.

For individual messages, you can create a single-use Segment while creating the message. Locations per composer:

ComposerSteps
Message, A/B TestIn the Audience step, select Target Specific Users, then build a Segment. Follow the steps in Target Specific Users.
SequenceA series of messages that is initiated by a trigger. Airship sends messages in the series based on your timing settings, and you can also set conditions that determine its audience and continuation. Sequences can be connected to each other and to other messaging components to create continuous user experiences in a Journey.Set Conditions when configuring the trigger and/or when adding each message. The procedures are the same as when creating a reusable Segment.

See Sequence triggers and Add messages to a Sequence.

In-App AutomationMessages cached on users’ devices and displayed when users meet certain conditions within your app, such as viewing a particular screen or opening the app a certain number of times., SceneA single or multi-screen in-app experience cached on users’ devices and displayed when users meet certain conditions in your app or website, such as viewing a particular screen or when a Custom Event occurs. They can be presented in fullscreen, modal, or embedded format using the default swipe/click mode or as a Story. Scenes can also contain survey questions.You cannot target Attributes directly. Instead, create a reusable Segment that includes Attributes, then select that Segment in the Audience step in the composer. Follow the steps in Target Specific Users: In-App Automation.

Required: iOS SDK 14.2+Android SDK 14.1+

You can also create reusable Segments instead of having to recreate your audience selections. See Segments.

Targeting using the API

Use the Attributes audience object to target any Attribute type.

For Text, Number, and Date Attributes, use the Attribute ID as the value for attribute and specify a comparison operator and Attribute value. precision is also required for some operators for Date Attributes. For more information, see:

Example push targeting a Text Attribute
POST /api/push HTTP/1.1
Authorization: Basic <master authorization string>
Accept: application/vnd.urbanairship+json; version=3
Content-Type: application/json

{
    "audience": {
        "attribute": "item_purchased",
        "operator": "contains",
        "value": "jeans"
    },
    "device_types": [
        "ios",
        "android",
        "web"
    ],
    "notification": {
        "alert": "Hello from Airship"
    }
}

Example push targeting a Date attribute
POST /api/push HTTP/1.1
Authorization: Basic <master authorization string>
Accept: application/vnd.urbanairship+json; version=3
Content-Type: application/json

{
    "audience": {
        "attribute": "account_creation",
        "operator": "equals",
        "value": "2023-05-24",
        "precision": "year_month_day"
    },
    "device_types": [
        "web"
    ],
    "notification": {
        "alert": "Hello from Airship"
    }
}

Use boolean NOT or AND operators to create compound audience expressions. In the following example, the NOT operator gives you the same result as if you had used the “Does not contain” operator building a Segment in the dashboard. For more about boolean audience operators, see Audience Selection: Compound Selector in the Data Formats section of our API reference.

NOT operator
{
    "NOT": {
        "attribute": "item_purchased",
        "operator": "contains",
        "value": "jeans"
    }
}

AND operator
{
    "AND": [
        {
            "attribute": "size",
            "operator": "greater",
            "value": 12
        },
        {
            "attribute": "size",
            "operator": "less",
            "value": 15
        }
    ]
}

For JSON Attributes, the Attributes audience object must contain the Attribute ID as the value for attribute and a where object. The where object defines a property as a JsonPath expression, the property value, a comparison operator, and the property type as a compare_as value. See JSON Attributes Selector for more information.

Audience object for a JSON Attribute
{
    "audience":{
        "attribute": "books_on_books",
        "where":{
            "property": "$.x.store.book[*].title",
            "operator": "equals",
            "value": "Dracula",
            "compare_as": "text"
        }
    }
}

For details and more example requests, see Attributes in the Data Formats section of our API reference.


As in the dashboard, you can create reusable Segments instead of having to recreate your audience selections. See Segments in our API reference.

Operators

Operators per Attribute type:

Attribute typeOperatorsAPI reference
Textequals, contains, less, greater, is_emptyText Attribute Selector
Numberequals, contains, less, greater, is_emptyNumber Attribute Selector
Dateequals, before, after, is_empty, rangeDate Attribute Selector
JSONequals, contains, not_contains, less, greater, is_empty, not_empty1JSON Attribute Selector
1. If the JsonPath expression maps to an array, the only available operators are is_empty, not_empty, contains, or not_contains.

The same operators are available when creating a Segment in the dashboard, but some have slightly different labels, like “Does not contain” instead of not_contains.