# Event tracking

## Event Tracking API

Event Tracking allows Neuralens to learn from a user's behavior and personalize the results for them.

<mark style="color:green;">`POST`</mark> `https://api.neuralens.ai/analytics/event`

### Request Headers

| Header                     | Value                       |
| -------------------------- | --------------------------- |
| X-Neuralens-API-Key        | Bearer YOUR\_API\_KEY\_HERE |
| X-Neuralens-Application-ID | YOUR\_APPLICATION\_ID       |

### Request Body

```json
{
    "uid": "3845",
    "items": [
        {
            "id": "AV768"
        }
    ],
    "query": "solid wood chair",
    "page": "SEARCH_RESULT_PAGE",
    "event": "CLICK_PRODUCT",
    "index": 3,
    "geo": {
        "lat": 31.34956697190882, 
        "long": 78.44615274878441,
        "region": "MG Road",
    },
    "timestamp": 1715644800
}
```

`uid` user id. For anonymous users, send anonymous uuids if available, or null

`items` id of the product for which the event is triggered. This can contain multiple product ids in case event=PURCHASE. In all other cases it should contain a single product id.

`index` The index of the product/suggestion that is viewed, clicked, favorited or added to cart. Index values start at 0&#x20;

`query` The search query text. For example, if a user adds items to cart from search results page, the ADD\_TO\_CART event object should contain the respective query text.&#x20;

`geo` Location details of the user at the time of event. lat and long are the user's coordinates. *region* is the name of the region at the level at which user behavior matters in your scenario. This could be a locality, city, city-country, state, or any other internal nomenclature you use depending upon the use case.

**Values for Page**

The Page parameter defines the page where the event took place

* SEARCH\_RESULT\_PAGE - Search Result Page
* AUTOCOMPLETE - Search Autocomplete
* CATEGORY\_PAGE - All merchandising pages
* PRODUCT\_PAGE - Product Details Page

**Values for Event**

The Event parameter defines the type of event

* VIEW\_PRODUCT
* CLICK\_PRODUCT
* VIEW\_SUGGESTION (Autocomplete suggestion)
* CLICK\_SUGGESTION (Autocomplete suggestion)
* LAND\_PRODUCT\_PAGE
* FAVORITE
* SHARE
* ADD\_TO\_CART
* PURCHASE

### Response&#x20;

```json
{
    "status": "success",    // or failure
    "message": ""    // failure message
}
```
