Events Quick Links
- Builder.postEvent(url, event, onSuccess, onError)
- Builder.getEvents(url, since, until, contactId, scope, eventTypes, offset, limit, onSuccess, onError)
Events
Builder.postEvent(url, event, onSuccess, onError)
Post an event.
Parameters
Name | Type | Description |
---|---|---|
url | String | The endpoint of your server that handles posting an event. |
event | Object | The event object. (see example) |
onSuccess | Function | On success callback function. |
onError | Function | On error callback function. |
Example
Builder.postEvent() example
const url = 'https://yourserver.com/api/events/post'
const event = {
'event_type': 'store_purchase',
// The content can be anything, as long as it is an object
'content': {
'store_id': 'appmachine',
'card_id': '09102017133515',
'order_number': '61017114657'
}
}
const onSuccess = (response) => {
console.log(response)
}
const onError = (response) => {
console.log(response)
}
Builder.postEvent(url, event, onSuccess, onError)
Builder.getEvents(url, since, until, contactId, scope, eventTypes, offset, limit, onSuccess, onError)
Get events.
Parameters
Name | Type | Description |
---|---|---|
url | String | The endpoint of your server that handles getting events. |
since | Number | Unix timestamp to get events since a certain date/time. |
until | Number | Unix timestamp to get events until a certain date/time. |
contactId | String | A contact id. (can be an empty String) |
scope | String | The scope of the event. This can be ‘app’ or ‘site’. |
eventTypes | String | Comma separated string of event types to filter. (can be an empty String) |
offset | String | An offset for the events to get. |
limit | Number | Limit the number of events to get. |
onSuccess | Function | On success callback function. |
onError | Function | On error callback function. |
Example
Builder.getEvents() example
const url = 'https://yourserver.com/api/contacts/get'
const since = new Date(2017, 6, 6).getTime()
const until = new Date().getTime()
const contactId = '123e4567-e89b-12d3-a456-426655440000'
const scope = 'app'
const eventTypes = 'new_order,new_contact'
const offset = '0'
const limit = 50
const onSuccess = (response) => {
console.log(response)
}
const onError = (response) => {
console.log(response)
}
Builder.getEvents(url, since, until, contactId, scope, eventTypes, offset, limit, onSuccess, onError)