Events encompass users' actions within your application, on your website, and more. These actions may include clicking buttons, scrolling to the bottom of a page, or purchasing. By providing us with event data, you can initiate campaigns and categorize your user base according to their interactions or lack thereof within your application.

What are Events?

While a contact's attribute conveys information about an individual, an event captures specific, time-bound actions performed by that person. When working with Naxai's APIs and SDKs. Events can serve various purposes, such as triggering campaigns or shaping contact segments, allowing you to tailor your responses to individual actions on your website or within your application.

Each event comprises an event name and accompanying data. The event name serves as the means to identify and target events within Naxai, while the data contains information you can reference in liquid templates, segment criteria, and similar contexts.

Structure of Events

Event data exhibits flexibility in terms of its structure. However, maintaining a consistent data structure for events with identical names is usually beneficial. This uniformity enables the utilization of event data in liquid templates to present pertinent information in messages or to filter individuals who engaged in the same event but possess distinct values or data.

The technique for transmitting event data undergoes slight variations contingent upon your integration. Nevertheless, using conventional JSON dot notation, you can access nested event data in your campaigns, segments, and other relevant contexts.

{
    "name": "purchase",
    "data": {
        "items": [
            {
                "product": "video game",
                "price": 100
            },
            {
                "product": "memory",
                "price": 50
            }
        ]
    	"total": 150
    }
}

How to send Events?

The method you select for transmitting events hinges on the communication channels you've chosen for engaging with your audience and the particular event types you intend to manage. To transmit events to Naxai, you can opt to pick one or multiple of these methods:

Uploading a CSV file

You can upload contacts with event data from the import contacts.

You may choose to do this if you have to input events your audience undertook through methods other than your regular integration process, such as actions they took before you connected with Naxai. For further details on uploading a CSV, please refer to the section on uploading contacts.

The column header creates the event property; only strings, numbers, and boolean can be used.
Arrays and Objects cannot be passed using the file upload and will be converted to strings.
Properties of Events and attributes are case sensitive, then event.data.amount and event.data.Amount are two different properties of an event.

Automatic upload of Events using FTP Connector

You can automate the ingestion of Contacts and Events using an FTP connector.

Sending Events using the API

When sending Events using the API, you pass the event's name in the name and your properties in the data object.

For example, if you send an event representing a person’s purchased items like the example below, you could create a segment of people who purchased a keyboard using the event.data.items[].product is "keyboard".

curl --request POST \
     --url https://api.naxai.com/people/contacts/{identifier}/events \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "name": "purchase",
  "type": "event",
  "data" : 
  	{
    "items": [
            {
                "product": "keyboard",
                "price": 100
            },
            {
                "product": "mouse",
                "price": 50
            }
        ],
    "total": 150
    }
}
'

Deduplicating Events with idempotencyKey

You can include an identification key called idempotencyKey with your events to avoid counting the same event more than once if your integration might send duplicate events. This identification key can be in any format but cannot exceed 128 characters. If two events share the same identification key, we won't process the event multiple times for a period of 24 hours.

Deduplicating events serves several purposes: it ensures that people's actions are accurately recorded, prevents individuals from mistakenly joining or leaving campaigns based on the number of times they perform an event, and safeguards your data by avoiding the impact of duplicate events.

{
    "name": "purchase",
  	"idempotencyKey" : "My-unique-key",
    "data": {
        "items": [
            {
                "product": "video game",
                "price": 100
            },
            {
                "product": "memory",
                "price": 50
            }
        ]
    "total": 150
    }
}

Back-date events with event timestamps

When you transmit an event, you can include a timestamp that represents the event's specific date. It's essential to format this timestamp value as a Unix timestamp, which counts the seconds elapsed since the epoch. It's crucial to exercise caution when retroactively inserting events, as events can act as triggers for campaigns. Before dispatching events with earlier dates, ensure you don't unintentionally activate campaigns or send inconsequential messages to your audience.

In cases where you don't provide a timestamp, we will use the time the event is processed as the default timestamp.

{
    "name": "purchase",
    "timestamp" : 1696252121,
    "data": {
        "items": [
            {
                "product": "video game",
                "price": 100
            },
            {
                "product": "memory",
                "price": 50
            }
        ]
    "total": 150
    }
}