First steps
Events and Behaviour Tracking
User Data
- Email Builder Review
- Designing your email
- Creating a Synchronized Module
- Setting Responsivity
- Building Smart Containers
- Creating a Gmail Promotions Annotation
- Adding a Rollover Effect
- Adding a Background to an Email
- Adding Anchor Links
- Adding a Video to an Email
- Adding a Table to an Email
- Adding a Custom Font
- Adding Social Media Buttons
- Editing HTML and CSS
- Working with “Images” block
Omnichannel
Automation
Personalization
Analytics
Multilanguage Campaigns
Recommendations
API
Security and Compliance
Integration
How to Use the Generate event API Resource
The Generate event resource can be used to transfer to the email any custom data:
- Login/password change or reset;
- Order;
- Abandoned browse and cart;
- Unfinished registration;
- Customer activity on the website or in app.
The resource generates an event that further triggers a workflow to send a message, create or update a contact.
For Abandoned Browses and Carts
Request sample:
{
"eventTypeKey": "abandoned_cart",
"keyValue": "site@com.net",
"params":
[
{
"name": "email",
"value": "site@ukr.net"
},
{
"name": "items",
"value":
{
"array":
[
{
"name": "Hair styler",
"price": "341",
"url": "https://site.com/catalog/suhaya-detskaya-molochnaya-smes-hipp-combiotic-2-750-g",
"imageurl": "https://site.com/uploads/product/big/20161122/20161122_7zvb.jpg",
"brand": "Le Petit Olivier",
"tags_weight": "200",
"tags_oldprice": "467"
},
{
"name": "Magnolia Nobile Парфумована вода",
"price": "2341",
"url": "https://site.com/catalog/suhaya-detskaya-molochnaya-smes-hipp-combiotic-2-750-g",
"imageurl": "https://site.com/uploads/product/big/20161122/20161122_7zvb.jpg",
"brand": "Acqua Di Parma",
"tags_weight": "100",
"tags_oldprice": "4467"
}
]
}
}
]
}
eventTypeKey is a string identifier for the event type. If it did not exist before, after the first request it will appear in the account, and you can see it in the Automation → Event types section.
To view the event body, go to Automation > Event history and click the necessary event.
- keyValue is the event key;
- params are event parameters that can be used in a workflow. Their number is unlimited.
An array is a required format for the event {"name," "value": "site@en.net."}
This means that the data contains a variable email with the value of site@en.net. It should be specified in the workflow > block Email > Contact’s email for the email to be sent to site@en.net.
The array contains two items (two products here) with a set of variables: name, price, url, imageurl, brand, tags_weight, tags_oldprice. The number of items is unlimited. The names of variables are arbitrary.
To use the array data in the message, in the block Email > JSON, specify the name of the field items:
You insert the data from the request into the message using Velocity.
To refer to the data, use the following loop:
$!item.get('name')
$!item.get('price')
$!item.get('url')
$!item.get('imageurl')
$!item.get('brand')
$!item.get('tags_weight')
$!item.get('tags_oldprice')
You can refer to the array elements straight with the index (order starts at 0). This method can cause errors in content substitution if an element is absent.
First element:
$!data.get('array').get(0).get('name')
$!data.get('array').get(0).get('price')
$!data.get('array').get(0).get('url')
$!data.get('array').get(0).get('imageurl')
$!data.get('array').get(0).get('brand')
$!data.get('array').get(0).get(''tags_weight')
$!data.get('array').get(0).get('tags_oldprice')
Second element:
$!data.get('array').get(1).get('name')
$!data.get('array').get(1).get('price')
$!data.get('array').get(1).get('url')
$!data.get('array').get(1).get('imageurl')
$!data.get('array').get(1).get('brand')
$!data.get('array').get(1).get(''tags_weight')
$!data.get('array').get(1).get('tags_oldprice')
The number of elements is unlimited.
Important!
Use variables including the register as they are register-dependent. If an email contains $!item.get ('ImageUrl') and the request transfers imageurl, the variable won’t be inserted.
To view and check dynamic data in the email, click Additional settings > Configuring dynamic content.
Insert the array with dynamic data and click View message.
- In case of an error in the dynamic content substitution, check Velocity syntax in the message.
- If you see the Wrong Format error, check the JSON request body.
- If there are no errors but the data isn’t inserted in preview, check whether the variables in the request and variables in the email correspond and whether variables are referred to correctly.
- If there are no errors and the data is substituted correctly, run a test by sending an API request to the account.
To Create or Update a Contact
Request sample:
{
"eventTypeKey": "create_contact",
"keyValue": "site@com.net",
"params":
[
{
"name": "email",
"value": "site@ukr.net"
},
{
"name": "phone",
"value": "380501234567"
},
{
"name": "externalCustomerId",
"value": "AV13760"
},
{
"name": "json",
"value":
{
"profileInputs":
[
{
"profileInputId": 10001,
"value": "2020-11-23"
}
]
}
}
]
}
where
- 10001 – id of the additional field.
- 2020-11-23 – value of the additional field.
Ensure the correctness of the transferred data:
- name and surname size (up to 60 characters);
- phone number in the international format (+1-541-754-3010);
- value of an additional contact field in the corresponding format.
In case of incorrect data transfer, the system will ignore the entire array and won’t add or update data in the contact card.
For correct workflow work, in the block Task (Create contact/Update contact), specify a variable ${email} in the field Contact’s email and a variable ${json} in the field JSON.
In addition to that the Generate event resource can be used to create or update a contact and to launch a workflow that will send messages with dynamic content, it can also be used to send orders to the system.