Personalize automations and sequences using custom events
When you trigger automated messages and sequences from custom events, you can personalize your messages with values from the custom event trigger.
Custom events help you track user activities and conversions from your app, website, etc. When you trigger an AutomationA set of conditions that your audience must meet before they receive a message. or a 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. with a Custom EventEvents that indicate that a user performed a predefined action, such as adding an item to a shopping cart, viewing a screen, or clicking an Unsubscribe button. Custom events can trigger automation, sequences, scenes, and surveys. You can code them into your app or website, or send them to Airship from an external source using the custom event API. Custom events contain properties
that you can use to personalize messages.
, you can use properties from the custom event to personalize the resulting messages. For sequences, you can reuse custom event properties in any message in the sequence, which can help remind your audience about items they left in their shopping cart, or that an event that they’re interested in is happening soon.
You can also personalize automated messages and sequences using AttributesMetadata that you can use for audience segmentation. Attributes differ from tags in that when evaluating users with attributes, Airship uses operators, e.g., equals, less than/greater than, contains, before/after, to determine whether or not to target a user. Supported attribute types are TEXT, NUMBER, and DATE. , even when you don’t use custom event triggers.
Custom events are associated with a channel or a named user and carry properties
that you can use to trigger and personalize your messages.
Start by creating an automation or a sequence using the Custom Event trigger, and select one or more custom eventsEvents that indicate that a user performed a predefined action, such as adding an item to a shopping cart, viewing a screen, or clicking an Unsubscribe button. Custom events can trigger automation, sequences, scenes, and surveys. You can code them into your app or website, or send them to Airship from an external source using the custom event API. Custom events contain properties
that you can use to personalize messages. (or event properties) to trigger the automation or sequence.
When writing your message, you can reference properties from the custom event trigger in your message or template. For example, you could iterate over the items a user purchased by referencing an “items_purchased” property.
{{#each items_purchased}}
{{qty}} x {{item_name}} = {{item_total}}
{{/each}}
{{total}}
If you reference a property that is not in an event, is null, or empty, the reference will be empty in your message, and your message may not make sense. Use the default handler $def
to set default values, so that your message still makes sense if variables are empty or absent. For example, {{$def name "you"}}
would insert you
in the message if the name
property in your custom event is empty or missing.
Custom event personalization example
When personalizing messages or templates for a custom event-triggered automation or sequence, you can use anything in the custom event’s properties
object.
The following is an example custom event. We will use that to send a personalized receipt in a Message Center message.
{
"occurred": "{{event_time}}",
"user": {
"named_user_id": "user"
},
"body": {
"name": "purchase",
"subscribe": true,
"properties": {
"customer_name": "Dave",
"total": 48,
"cost_units": "USD",
"purchase": [
{
"qty": 4,
"item": "MLB regulation baseball",
"per": "$12",
"total": "$48"
},
{
"qty": 2,
"item": "MLB official hat",
"per": "$15",
"total": "$30"
}
]
}
}
}
Because custom event properties can include arrays, objects, and arrays of objects, we can loop through complex custom event properties using {{#each}}
.
Next we put it all together with the default handler to craft the message.
Hi {{$def customer_name "valued customer"}}!
Thanks for your purchase of:
{{#each purchase}}
{{qty}} x {{per}} {{item}} = {{this.total}}
{{/each}}
total: ${{total}} {{cost_units}}
Your order is being processed. We'll message you again when it ships!
The result will look like this:
Hi Dave!
Thanks for your purchase of:
4 x $12 MLB regulation baseball = $48
2 x $15 MLB official hat = $30
total: $78 USD
Your order is being processed. We'll message you again when it ships!
Categories