title | description | icon |
---|---|---|
Analytics with Trieve |
Learn how to get started with Trieve Analytics |
chart-mixed |
Trieve Analytics is a powerful tool that allows you to analyze your queries and gain insights from them.
Trieve automatically collects all of the searches and RAG chats that are made in your dataset. You don't have to worry about manually tracking them.
We provide extensive analytics on your searches all of which can be found in the search analytics route. These analytics include:
- Head Queries: Head queries is a collection of the most common queries.
- Low Confidence Queries: The queries where all your results have scores, which can be useful for improving your search results.
- No Results Queries: This table shows the queries that returned no results, which can be useful for improving your search results.
- Popular Filters: This table shows the most popular filters used in searches.
- Latency / time: This graph shows the average latency of searches over time.
- Searches / time: This graph shows the number of searches made over time.
You can see all of this data on the dashboard in the analytics section, as well as be able to export them to a CSV so that you can analyze them in your own tools.
We provide extensive analytics on your RAG chats all of which can be found in the RAG analytics route. These analytics include:
- Usage over time: This graph shows the number of RAG chats made over time.
- All RAG Chats: This table shows all of the RAG chats made in your dataset.
You can see all of this data on the dashboard in the analytics section, as well as be able to export them to a CSV so that you can analyze them in your own tools.
All searches, recommendations, and chats return a requestID
. With this you can track:
- Clicks
- user ratings (on any scale you want)
- Add to Cart's
- User Views
- Purchase's
forwarding this query_id
to any custom
All Searches Return an id
, this id
is your Request ID
{
"chunks" : [
// ... Your search response
],
"id": "28f37011-179e-4927-9138-771132d0b6c3" // Request ID
}
Calls to /api/chunk/recommend
return an id
{
"chunks" : [
// ... Your Chunk Data
],
"id": "28f37011-179e-4927-9138-771132d0b6c3" // Request ID
// ... other data
}
Calls to /api/message
return a streaming response so the id is not located in the payload, the id is instead placed on the header TR-QueryID
.
Send Click-Through Rate data to Trieve using the send CTR data route. Referencing your search id
from the previous step.
chunk_id
in this case is the chunk the user clicked on from the search
import { TrieveSDK } from "trieve-ts-sdk";
let search_id = ""; // Set your search_id here
let chunk_id = ""; // The chunk clicked
let api_key = "tr-**************"; // Your api key here
export const trieve = new TrieveSDK({
apiKey: "tr-********************************",
datasetId: api_key,
});
const data = await trieve.sendCTRData({
ctr_type: "search | rag",
clicked_chunk_id: chunk_id,
position: 1,
request_id: search_id,
});
You can also send user feedback to the Trieve API using the rate search query route or rate RAG query route.
The rating
parameter can be any number of your choosing. Feel free to make your own rating scales
curl -X POST https://api.trieve.ai/api/analytics/rate-search \
-H "TR-Dataset: YOUR_DATASET_ID" \
-H "Authorization: YOUR_API_KEY" \
-d '{
"query_id": "<your-request-id>",
"rating": 5,
"note": "Great results!"
}'
import { TrieveSDK } from "trieve-ts-sdk";
let search_id = ""; // Set your search_id here
let api_key = "tr-**************"; // Your api key here
export const trieve = new TrieveSDK({
apiKey: "tr-********************************",
datasetId: "<your-api-key>",
});
const data = await trieve.rateSearchQuery({
query_id: search_id,
rating: 5,
note: "Great results!",
});
You can send custom events to the Trieve API using the send event route. Referencing your search id
from the previous step
curl -X POST https://api.trieve.ai/api/analytics/event \
-H "TR-Dataset: YOUR_DATASET_ID" \
-H "Authorization: YOUR_API_KEY" \
-d '{
"event_type": "add_to_cart",
"event_name": "Add to Cart",
"items": [
"Cheesesticks",
"Pizza",
],
"request_id": "<your-request-id>"
}'
import { TrieveSDK } from "trieve-ts-sdk";
let search_id = ""; // Set your search_id here
let api_key = "tr-**************"; // Your api key here
export const trieve = new TrieveSDK({
apiKey: "tr-********************************",
datasetId: api_key,
});
const data = await trieve.sendEventData({
event_type: "add_to_cart",
event_name: "Add to Cart",
items: ["Cheesesticks", "Pizza"],
request_id: search_id,
});
You can query this custom event data using the get all events route. This will return all of the custom events that you have sent to the Trieve API.
curl --request POST \
--url https://api.trieve.ai/api/analytics/events \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '{
"filter": {
"date_range": {
"gt": "2021-08-10T00:00:00Z",
"lt": "2021-08-11T00:00:00Z"
},
"event_type": "<your_event_type>",
"is_conversion": true,
"metadata_filter": "path = \"value\"",
"user_id": "user1"
}
}'