Track Event
Track a user event with metadata for semantic clustering and journey tracking
Overview
The/track endpoint is the core of Turret’s API. Use it to send user events with metadata for automatic semantic clustering and journey tracking.
Request Body
session_id in subsequent messages to connect them into a conversation.Example Request
First Message (IDs Auto-Generated)
Subsequent Messages (Include IDs)
Response
Example Response
How It Works
- Event Ingestion: When you POST an event, Turret stores it with its metadata.
- Embedding Generation: Turret generates a vector embedding for the metadata value (e.g., the prompt text) using an embedding model.
-
Semantic Clustering: Events are grouped into clusters based on embedding similarity. Similar prompts end up in the same cluster, even if they use different words:
- “How do I reset my password?” and “I forgot my login credentials” → Same cluster
- Cluster Labeling: Clusters are automatically labeled with human-readable descriptions using an LLM (e.g., “Password Reset Requests”).
-
Journey Tracking: When events share the same
session_id, Turret tracks transitions between clusters:- User asks about pricing (Cluster A)
- User asks about features (Cluster B)
- User asks about pricing again (Cluster A)
- This creates a journey: A → B → A
Common Use Cases
Track User Messages (Minimal)
session_id and user_id - store these for subsequent messages.
Track with Your Own IDs
Track Search Queries
Track with Additional Context
Error Responses
Invalid API Key (401)
Missing Required Fields (400)
Rate Limit Exceeded (429)
Best Practices
Session ID Management
- First message: Omit
session_id- Turret generates one - Store the response: Save the returned
session_id - Subsequent messages: Always include the stored
session_id - New conversation: Omit
session_idagain to start fresh
Using Your Own IDs
If you already have conversation IDs (most apps do):- Pass your conversation ID as
session_id - Pass your user ID as
user_id - Turret uses your IDs as-is
Event Names
- Use descriptive names (e.g., “user_message”, “search_query”)
- Keep names consistent across your app
- Avoid generic names like “event” or “action”
Metadata Structure
- Include the user’s actual text in the
promptorqueryfield - Keep text fields under 10,000 characters
- Additional metadata fields provide context but aren’t clustered
Error Handling
- Check response status codes
- Implement retry logic with exponential backoff
- Don’t let tracking failures break your main application flow
Authorizations
Your project API key from the Turret dashboard
Body
Event data to track
Event name (e.g., 'user_prompt', 'search_query'). Used to categorize events.
1 - 255"user_prompt"
Object containing the data to cluster. The key (e.g., 'prompt') becomes the clustering dimension. The value is the text that gets semantically clustered.
{ "prompt": "How do I reset my password?" }Your conversation/thread ID. Critical for journey tracking. Events with the same session_id are connected into a user flow.
"conv_abc123"
Your user's ID. Enables cross-session analysis (tracking the same user across multiple conversations).
"user_456"