Segmentation

You can define your audience based on tags, named users, tag groups, and attributes.

Addressing Devices

To help target specific devices or users for a notification, we have Tags, Named Users, Tag Groups, and Attributes.

Tags

Tags are an easy way to group channels. Many tags can be applied to one or more devices. Then, a message sent to a tag will be sent out to all devices that are associated with that tag.

Modifying tags
const sdk = await UA

await sdk.channel.editTags()
  // Add a tag
  .add(group, tag)
  // Remove a tag
  .remove(group, tag)
  // Replaces all tags for the given tag group with `tags`
  .set(group, tags)
  // applies all previously queued mutations
  .apply()

Tags are applied asynchronously and will be retried if the application fails due to a network failure.

Named Users

Named Users allow you to associate multiple devices to a single user or profile that may be associated with more than one device, e.g., an end-user’s Chrome browser on their laptop and their iPhone. A device can have only one Named User, and a single Named User should not be associated with more than 100 devices. Named Users provide the ability to directly set tags on them (see Tag Groups).

 Note

Associating the channel with a Named User ID, will implicitly disassociate the channel from the previously associated Named User ID, if it existed.

By default, Named Users can only be associated server-side. A 403 Forbidden response is returned if Named User association is attempted when client-side association is disabled. In order to associate a Named User through the project, you must change the project’s Named User security setting to allow Named Users to be set from devices. Client-Side Named User Association.

Setting the Named User
const sdk = await UA

// Set the Named User to a String
await sdk.contact.identify(name) // associates this channel with a Named User

// Remove the currently associated Named User
await sdk.contact.reset() // Disassociates the channel from the Named User
 Note

A Named User that has not been identified yet is referred to as an “anonymous contact.” You may set tags and attributes on a contact even if it has not yet been identified.

Tag Groups

A tag group is an array of tags that you can associate with both channels and Named Users. In addition to the Airship default tag groups, you can create custom tag groups in the dashboard. See the Tag Groups documentation for more details, including security information.

Contact Tag Group Examples
const sdk = await UA

await sdk.contact.editTags()
  // Add channel tag to a group
  .add('group-name', 'tag-name')
  // …or add multiple at a time
  .add('other-group-name', ['tag-name-1', 'tag-name-2'])
  // Remove channel tag from a group
  .remove('group-name', 'tag-name')
  // Set channel tags on a group named `loyalty`
  .set('loyalty', ['silver-member', 'gold-member'])
  // apply the above mutations
  .apply()
Channel Tag Group Examples
const sdk = await UA

await sdk.channel.editTags()
  // Add channel tag to a group
  .add('group-name', 'tag-name')
  // …or add multiple at a time
  .add('other-group-name', ['tag-name-1', 'tag-name-2'])
  // Remove channel tag from a group
  .remove('group-name', 'tag-name')
  // Set channel tags on a group named `loyalty`
  .set('loyalty', ['silver-member', 'gold-member'])
  // apply the above mutations
  .apply()

Attributes

Attributes are metadata used for audience segmentation and personalization. They extend the concept of Tags by adding comparison operators and values to determine whether or not to target a user, helping you better evaluate your audience.
Contact Attributes Example
const sdk = await UA

await sdk.contact.editAttributes()
  // set attribute `firstName`
  .set('firstName', 'John')
  // set attribute `lastName`
  .set('lastName', 'Doe')
  // apply the above mutations
  .apply()
Channel Attributes Example
const sdk = await UA

await sdk.channel.editAttributes()
  // set attribute `firstName`
  .set('firstName', 'John')
  // set attribute `lastName`
  .set('lastName', 'Doe')
  // apply the above mutations
  .apply()