What are custom events
enKod allows you to track a variety of events on your website or application. Among them: product or page views, changes to baskets, favourites, orders and order returns. At some point, you may need to customise the mechanics based on a specific event that we haven't provided.
In this case, you can create a custom event, and based on it:
- segment the base
- send messages
- run scenarios
A custom event is an HTTP API request or a JS script method that you create in the service, call it in a way convenient for you and transmit it to us from your website, from an internal service, a mobile application and any necessary system. Inside a custom event, you can pass a set of parameters, which can also be used for segmentation. Event parameters will be created automatically if they were not created previously.
An event must always be assigned to a contact. Whichever transmission method you choose, transmission of the contact ID inside the event is required.
Event creation and parameters
Events are created in the Data ➔ Events.
An event must be created in the service before it is transmitted. Otherwise we will not record it. At the same time, it is not necessary to create parameters beforehand, we will create them automatically. You will only have to add names for them later.
Transmission of user events
API
Use the POST /customEvent/save method to send us the event.
Script
ekEvents.push('event', {email:'[email protected]', phone:'79000000000', params: {param1: 'value1'}});
where:
- event is the system name of the event created in the Data ➔ Custom events
- param - system name of parameter
- value - value of the parameter
The method may (optionally) include the contact’s email and/or phone number. If the email and/or phone number are not transmitted or contacts with such identifiers are not found in the account, then we will associate the event with the session if we know it. If linked to a session and if it is not present (and there is no email or phone number transferred to your account), the event will not be displayed in enKod.
Event log
In the same section Data ➔ Events in the “Event History” tab, you can view the entire history of custom events that you have sent to us over time. Using history, you can search for the events themselves, as well as the contacts that were transferred to them.
By clicking on the event name, details will be displayed - parameters and values that were created.
Segmentation by user events
Segmentation by user events with subconditions on event parameters is available for all parameter data types: string, date, date-time, number, fractional and logical.
Start script when receiving a custom event
In scenarios, you can set up the initial “User Event” block by specifying restrictions on the parameter values of this event, if necessary. In this case, when the specified event is received, the scenario will be launched for the user specified in the request.
Custom events and session
You can create sessions to contacts using script or using the API method. These sessions can be used to handle custom events.
Custom events sent without email or phone number will not be recorded in the interface, but we will still store them in the database. At some point, a contact may authorize on the site, and we can associate the session (which is already stored) with the identifier (which the contact used when authorizing). In this case, we will load all the events of this contact into the event history (and populate his card with the events he performed before authorization).