If you would like to send custom events from the frontend integration for your users (e.g. add to wishlist, add to product compare, etc.), this is the way to do it.
The benefit of using the frontend integration as oppsoed to the Custom Event API is that it’s easier to implement, and it works for anonumous users.
In order to send custom events, you need to call Releva.push as usual, and also add the events array:
Releva.push(<accessToken>, {
page: {...},
profile: {...},
cart: {...},
events: [
{
tags: ['foo', 'bar'],
action: 'surveyInteraction',
timestamp: '2021-02-09T09:12:17.317Z',
products: [
{id: '123'},
{id: '234'}
],
custom: {
string: [
{
key: 'q1',
values: [
'answer1'
]
},
{
key: 'q2',
values: [
'answer2'
]
}
]
}
}
]
}, cb, errorCb, opts);
The events Array #
This object is an array of Objects with the following properties.
Field | Type | Description |
---|---|---|
tags | Array[String] (Optional) | The tags associated with this event. You can use this data to build segments and trigger campaigns based on custom events. |
action | String | The name of the action which this event refers to. You can use this data to build segments and trigger campaigns based on custom events. |
products[].id | String (Optional) | Products identifiers associated with this event. |
timestamp | ISO-8601 String (Optional) | The date and time when this event happened. |
custom | Object (Optional) | The custom fields associated with the event. |
Response Format #
A successful response contains the standard push response as shown in the Frontend Integration Guide.
An error response will return a HTTP 4xx
or 5xx
status code and have the following structure:
{
"message": "A description of the error and how to fix it, if it's a client error."
}