Agent Analytics measures your AI agent’s conversations inside your product: who uses the agent, what they ask, how satisfied they are, and where the agent fails. You send the conversation as it happens; Userpilot automatically derives topics, frustration signals, failure signals, and slow-response flags — you never classify anything yourself.
Before you start
You need two things you almost certainly already have:- The Userpilot SDK snippet installed on your pages.
- A call to
userpilot.identify(userId, ...)— agent events attach to this user. Events fired before identify are queued locally and sent right after it.
Step 1 — Turn the module on
The agent module is off by default. Enable it in your Userpilot settings object:Step 2 — Report messages as they happen
There is no “start conversation” call. The first message you send with a newconversationId creates the conversation automatically — just use your own chat-session id.
When the user sends a prompt:
messageId (your own message id — recommended), inputTokens, outputTokens, metadata (your own key/values), ts (epoch ms).
Step 3 — Report thumbs up / down
Optional — Send from your backend instead (or as well)
Tokens, model names, and full replies often only exist where inference runs. Your backend can send the same events over HTTP toPOST /v1/agent/events with these headers:
Authorization: Token YOUR_WRITE_TOKEN(your account write token — same as/v1/track)Content-Type: application/json
user_idmust be the same id you pass touserpilot.identify— that is what joins conversations to profiles and segments. Anonymous users are client-transport-only.- Invalid items are rejected with a
422and per-item errors; valid requests return202and are processed asynchronously. - Optionally pass
"context": { "pathname", "hostname", "session_id" }— forward the SDK session id if you want session-replay links on server-sent conversations.
Privacy controls
- Client-side:
agent.captureText: falsestops all free text from ever leaving the browser;agent.redaction: (text, field) => stringlets you scrub text before sending. - Admin-side (in Userpilot, no code): an “Enable capture of conversation content” toggle per environment, plus mask patterns (matched spans stored as
[REDACTED]) and excluded keywords (whole message stored as a masked placeholder). These are enforced at ingestion for every producer — SDK and backend alike. - If text is not captured, usage and feedback metrics still work, but AI-derived topics and frustration/failure signals will be unavailable.
What you’ll see in Userpilot
Launch checklist
-
identify ()runs before or alongside agent usage -
agent.enabled: trueinwindow.userpilotSettings -
trackMessagewired to both user prompts and agent replies, withconversationId+agentIdon every call -
trackFeedbackwired to your thumbs up / down - (Hybrid) backend posts messages with the same
user_idand sharedmessage_id - Privacy: decide text capture per environment; add mask patterns for things like card numbers