Create events
// -------------------------------------------------------------------------- //
// Create events. //
// -------------------------------------------------------------------------- //
// ---------------------------- Add to cart event --------------------------- //
POST {{baseUrl}}/projects/{{projectId}}/custom_events
Content-Type: application/json
Authorization: {{token}}
{
"event_type": "custom",
"key": "add_to_cart",
"description": "Event used to track users that have added the item to the cart."
}
###
// ------------------------- Started checkout event ------------------------- //
POST {{baseUrl}}/projects/{{projectId}}/custom_events
Content-Type: application/json
Authorization: {{token}}
{
"event_type": "custom",
"key": "started_checkout",
"description": "Event used to track users that has started the checkout flow."
}
###
// ------------------------ Completed checkout event ------------------------ //
POST {{baseUrl}}/projects/{{projectId}}/custom_events
Content-Type: application/json
Authorization: {{token}}
{
"event_type": "custom",
"key": "completed_checkout",
"description": "Event used to track users that has completed the checkout flow."
}Create three example events using the Create a Custom Event API endpoint.
Prerequisite
Before running this request, you must follow the instructions to configure your REST API cookbook.
Create a file
Create a file named create-events.rest and copy and paste the recipe into the file.
Configure API
{{baseUrl}}, {{projectId}}, and {{token}} are defined in the settings.json file. Ensure you have configured your Visual Studio Code project correctly. See Configure the Visual Studio Code REST Client.
POST {{baseUrl}}/projects/{{projectId}}/custom_events
Content-Type: application/json
Authorization: {{token}}Create add_to_cart event
Create an event with the key add_to_cart. Click Send Request in Visual Studio Code.
Copy and save the event ID for add_to_cart. You need it for the Create an experiment recipe.
This API call corresponds to the following in the UI:
{
"event_type": "custom",
"key": "add_to_cart",
"description": "Event used to track users that have added the item to the cart."
}The ### delimiter
The REST Client extension delimits multiple requests using ###. See Main features in the REST Client documentation.
Create started_checkout event
Create an event with the key started_checkout. Click Send Request in Visual Studio Code.
This API call corresponds to the following in the UI:
{
"event_type": "custom",
"key": "started_checkout",
"description": "Event used to track users that has started the checkout flow."
}Create completed_checkout event
Create an event with the key completed_checkout. Click Send Request in Visual Studio Code.
This API call corresponds to the following in the UI:
{
"event_type": "custom",
"key": "completed_checkout",
"description": "Event used to track users that has completed the checkout flow."
}