Personalize Automations and Journeys Using Custom Events

When you trigger automated messages and journeys 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 JourneyA series of messages that is initiated by a single automation trigger. Airship sends messages in the series based on your timing settings, and you can also set conditions that determine the continuation of the series. 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 and journeys. 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 journeys, you can reuse custom event properties in any message in the journey, 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.

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 journey 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 and journeys. 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 journey.

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 $def 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 journey, you can use anything in the custom event’s properties object.

Custom Event

{
   "occurred": "{{event_time}}",
   "user": {
      "named_user_id": "user"
   },
   "body": {
        "name": "purchase",
        "subscribe": true,
        "properties": {
            "customer_name": "user",
            "total": 48,
            "cost_units": "USD",
            "purchase": [
                {
                    "qty": 4,
                    "item": "MLB regulation baseball",
                    "per": "$12",
                    "total": "$48"
                }
            ]
        }
    }
}

Message Content

Hi {{$def customer_name "valued customer"}}!

Thanks for your purchase of:
{{#each purchased}}
{{qty}}x  {{per}}  {{item}} = {{this.total}}
{{/each}}
total: ${{total}}

Is being processed. We'll message you again when it ships!

Because custom event properties can include arrays, objects, and arrays of objects, you might want to loop through complex custom event properties using {{#each}}. Following the example above, we could confirm products in a customer’s recent order by looping through the products array.

Reference an array of products from a custom event:
{{#each products}}
{{qty}}x {{item}} = {{this.total}}
{{/#each}}
Total: {{total}} {{cost_units}}