---
title: "Send User Event Data"
method: PUT
path: "/api/analytics/events"
tags: ["Analytics"]
---

# Send User Event Data

`PUT /api/analytics/events`

This route allows you to send user event data to the system.

## Headers

- `TR-Dataset` string, uuid, required

## Request body

- union
  - object
    - `event_name` string, required — The name of the event
    - `event_type` 'view', required
    - `items` string[], required — The items that were viewed
    - `location` string, nullable — The location of the event
    - `metadata` unknown
    - `request` RequestInfo
      - `request_id` string, uuid, required
      - `request_type` 'search' | 'rag' | 'recommendation', required
    - `user_id` string, nullable — The user id of the user who viewed the items
  - object
    - `event_name` string, required — The name of the event
    - `event_type` 'add_to_cart', required
    - `is_conversion` boolean, nullable — Whether the event is a conversion event
    - `items` string[], required — The items that were added to the cart
    - `location` string, nullable — The location of the event
    - `metadata` unknown
    - `request` RequestInfo
      - `request_id` string, uuid, required
      - `request_type` 'search' | 'rag' | 'recommendation', required
    - `user_id` string, nullable — The user id of the user who added the items to the cart
  - object
    - `clicked_items` ChunkWithPosition
      - `chunk_id` string, uuid, required
      - `position` integer, required
    - `event_name` string, required — The name of the event
    - `event_type` 'click', required
    - `is_conversion` boolean, nullable — Whether the event is a conversion event
    - `location` string, nullable — The location of the event
    - `metadata` unknown
    - `request` RequestInfo
      - `request_id` string, uuid, required
      - `request_type` 'search' | 'rag' | 'recommendation', required
    - `user_id` string, nullable — The user id of the user who clicked the items
  - object
    - `event_name` string, required — The name of the event
    - `event_type` 'purchase', required
    - `is_conversion` boolean, nullable — Whether the event is a conversion event
    - `items` PurchaseItem[], required — The items that were purchased
      - `revenue` number, double, required
      - `tracking_id` string, required
    - `location` string, nullable — The location of the event
    - `metadata` unknown
    - `request` RequestInfo
      - `request_id` string, uuid, required
      - `request_type` 'search' | 'rag' | 'recommendation', required
    - `user_id` string, nullable — The user id of the user who purchased the items
  - object
    - `event_name` string, required — The name of the event
    - `event_type` 'filter_clicked', required
    - `is_conversion` boolean, nullable — Whether the event is a conversion event
    - `items` object, required — The filter items that were clicked in a hashmap ie. {filter_name: filter_value} where filter_name is filter_type::field_name
    - `location` string, nullable — The location of the event
    - `request` RequestInfo
      - `request_id` string, uuid, required
      - `request_type` 'search' | 'rag' | 'recommendation', required
    - `user_id` string, nullable — The user id of the user who clicked the items
  - object
    - `event_type` 'search', required
    - `latency` number, float, nullable — Latency of the search
    - `metadata` unknown
    - `query` string, required — The search query
    - `query_rating` SearchQueryRating
      - `metadata` unknown
      - `note` string, nullable
      - `rating` integer, required
    - `request_params` unknown
    - `results` unknown[], nullable — The results of the search
      - unknown
    - `search_type` 'search' | 'search_over_groups' | 'autocomplete' | 'rag'
    - `tokens` integer, required — Number of tokens used in the search
    - `top_score` number, float, nullable — The top score of the search
    - `user_id` string, nullable — The user id of the user who made the search
  - object
    - `detected_hallucinations` string[], nullable — The detected hallucinations of the RAG event
    - `event_type` 'rag', required
    - `hallucination_score` number, double, nullable — The hallucination score of the RAG event
    - `llm_response` string, nullable — The response from the LLM
    - `metadata` unknown
    - `query_rating` SearchQueryRating
      - `metadata` unknown
      - `note` string, nullable
      - `rating` integer, required
    - `rag_type` 'chosen_chunks' | 'all_chunks'
    - `results` unknown[], nullable — The results of the RAG event
      - unknown
    - `search_id` string, uuid, nullable — The search id to associate the RAG event with a search
    - `tokens` integer, required — The number of tokens used for this chat
    - `topic_id` string, uuid, nullable — The topic id to associate the RAG event with a topic
    - `user_id` string, nullable — The user id of the user who made the RAG event
    - `user_message` string, required — The user message
  - object
    - `event_type` 'recommendation', required
    - `metadata` unknown
    - `negative_ids` string[], nullable — Negative ids used for the recommendation
    - `negative_tracking_ids` string[], nullable — Negative tracking ids used for the recommendation
    - `positive_ids` string[], nullable — Positive ids used for the recommendation
    - `positive_tracking_ids` string[], nullable — Positive tracking ids used for the recommendation
    - `recommendation_type` 'Chunk' | 'Group'
    - `request_params` unknown
    - `results` unknown[], nullable — The results of the Recommendation event
      - unknown
    - `top_score` number, float, nullable — Top score of the recommendation
    - `user_id` string, nullable — The user id of the user who made the recommendation

## Response `204`

The event data was successfully sent

## Other responses

- `400` — Service error relating to sending event data

---

[API](https://skmtc.net/devflowinc/apis/trieve-api.md) · [All operations](https://skmtc.net/devflowinc/apis/trieve-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/devflowinc/trieve-api/revisions/84583e7c9fc1/schema)
