Access to the Event API is available only to Emma Plus, Premium and Enterprise customers.
In addition to personalizing a campaign's content using information stored in contact fields, you can customize automated campaigns based on custom API events. This gives you the ability to send super-targeted emails that can be personalized down to things like a contact’s specific purchase or appointment details. Head here for more information about triggering automated workflows using custom API events
Dynamic content with custom API events works similarly to personalization and the same operators from dynamic content can be used. You can find more info and a list of operators here.
The key difference between personalization based on contact information and personalization based on event attributes shared via the event API is a simple formatting distinction: while contact field personalization tags are prefixed with “member” - for instance, [% member:city %] - personalization based on event attributes (keys) are prefixed with “event”, such as [% event:purchase_amount %]. You must be familiar with the format of the events that you are sending to the event API in order to personalize your content using their key names.
The following example listens to an event for a “survey completion.”
The name of this survey (shared on the event as “survey_name”) is “Customer Satisfaction Survey,” and the message will be altered slightly based on whether or not a customer has indicated that they are satisfied (a reply of “7” or higher), or somewhat less than satisfied (a reply of “6” or less). Customer replies to this question are shared in the value for the key “overall_satisfaction.”
Thank you for taking our [% event:survey_name %]! [% if event:overall_satisfaction > “6”%] Please don’t ever hesitate to get in touch if there’s something you’d like to see from us! [% elif event:overall_satisfaction < “7” %] We never want you to be anything less than thrilled with our service, and we want to make things right. Please call us at 555.555.5555 if there’s anything at all that we can do to make things better for you. [% endif %]
Not all data from events shared with the Emma Event API will be neatly paired into top-level key/value pairs. Some event data is nested, meaning that one attribute (such as “line_items” in an order completed from an ecommerce platform) contains multiple related attributes (such as the item ids, names, prices and other related attributes).
Here is an example of the “line_items” data from such an order:
"title": “Slim Short Sleeve Linen Shirt”,
"name": “Slim Short Sleeve Linen Shirt - White“,
"title": "State Tax",
"title": “Slim Mens Chino”,
"name": “Slim Short Sleeve Linen Shirt - White“,
It’s common for marketers to want to use line items from an order and other nested sets of data in the content of their email. This could be used to tell users what they’ve left in their cart, to ask them to leave reviews on items that were purchased in a completed order, etc. This is possible using Emma’s dynamic content feature using an operator known as a for loop. A 'for loop' gives users the ability to look (or “loop”) over the individual attributes contained within a set of similar items (such as “line_items” in the above example), and to insert a piece of content into their email message for every item found within the set.
Let’s say that we wanted to insert a piece of content that would include the title, quantity and price of all items that were included within an order. It’s likely that this order contained multiple items, so we want them all to appear within the email, one after the other. Using a 'for loop', we would say that we wanted to search the event data for a specific attribute (“line_items” in this case), and we wanted to identify all nested attributes of that parent attribute as something consistent (we’ll say “item” here). At that point, we can use the attributes of that item to personalize the message. So the snippet below would produce a series of product descriptions (quantity, item title and price).
[% foreach context:event:line_items as item %]
[% context:item:quantity %], [% context:item:title %], [% context:item:price %]
[% endforeach %]
In addition to showing all items in an order (or other list), it’s possible to dynamically include the number of items in that list. For example, if you wanted to send an abandoned cart message that told users how many items had been left in their cart, you could do so using the following snippet:
[% length value=[% context:event:line_items %] %]
This gets really interesting if you want to show different messages based on how many items appear in a list. It’s possible that you’d format your message differently based on whether a customer had abandoned one item in their cart or multiple items.
This snippet will display the text “This is a test” if a customer has left more than one item in their cart, for example.
[% if [% length value=[% context:event:line_items %] %] > “1” %] This is a test [% endif %]