Bundle events and visitors
How to bundle events and visitors in a JSON object to improve performance of the Event API.
The examples below include the optional client_name
and client_version
fields. You should include these fields for debugging. For more, see the Event API reference.
Warning
A single JSON object must be 3.5 MB or less.
Bundle events
This example shows that a visitor was exposed to another variation and performed another tracked action on the site.
Note
The order of the events in the
events
array is not important.
{
"account_id": "1887578053",
"project_id": "7205579439",
"visitors": [
{
"session_id": "",
"visitor_id": "test_user",
"snapshots": [
{
"decisions": [],
"events": [
{
"key": "4841578001_view_optimizely_dev_docs",
"entity_id": "4841578001",
"revenue": 100,
"timestamp": 1491519130344,
"uuid": "145a44a2-6320-48d6-80d6-bff20b32cd65"
},
{
"key": "8766076075_click_view_docs",
"entity_id": "8766076075",
"revenue": 400,
"timestamp": 1491519130352,
"uuid": "3bb9371d-c245-4bf8-8086-5fef9f60cd06"
}
]
}
]
}
],
"anonymize_ip": true,
"client_name": "Optimizely/event-api-demo",
"client_version": "1.0.0",
"enrich_decisions": true
}
Bundle visitors
This example shows that a second visitor was exposed to a different variation of the same campaign and experiment as the first visitor. The second visitor performs one of the same tracked actions as the first visitor.
{
"account_id": "1887578053",
"project_id": "7205579439",
"visitors": [
{
"session_id": "",
"visitor_id": "test_user",
"snapshots": [
{
"decisions": [],
"events": [
{
"key": "4841578001_view_optimizely_dev_docs",
"entity_id": "4841578001",
"revenue": 100,
"timestamp": 1491519130344,
"uuid": "145a44a2-6320-48d6-80d6-bff20b32cd65"
},
{
"key": "8766076075_click_view_docs",
"entity_id": "8766076075",
"revenue": 400,
"timestamp": 1491519130352,
"uuid": "3bb9371d-c245-4bf8-8086-5fef9f60cd06"
}
]
}
]
},
{
"session_id": "",
"visitor_id": "another_test_user",
"snapshots": [
{
"decisions": [],
"events": [
{
"key": "4841578001_view_optimizely_dev_docs",
"entity_id": "4841578001",
"revenue": 400,
"timestamp": 1491519130362,
"uuid": "899de30f-fa1b-440c-b8a8-75a18da104a2"
}
]
}
]
}
],
"anonymize_ip": true,
"client_name": "Optimizely/event-api-demo",
"client_version": "1.0.0",
"enrich_decisions": true
}
Updated 4 months ago