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:
inputTokens, outputTokens, metadata (your own string, number, boolean, or null values), ts (epoch ms). If you omit messageId, the SDK generates one; provide your own for safe retries and to link feedback to a reply.
Step 3 — Report thumbs up / down
Send agent events from your backend (optional)
You can send agent events from your backend instead of the browser SDK, or use both. This is useful when tokens, model names, response times, and full replies are only available where inference runs. Send 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
Choose how conversation text is handled before you start sending it. These controls apply to messagetext and optional feedback reason; IDs, roles, and ratings are still sent.
To redact text in the browser, add a
redaction callback to window.userpilotSettings.agent:
"text" or "reason") and must return the string to send. In this example, "Show internal-project-name activity" becomes "Show [REDACTED] activity". The callback runs for both user prompts and agent replies, as well as feedback reasons, when text capture is enabled. It does not inspect metadata or process events posted directly by your backend.
Admin controls are configured in Userpilot without code and enforced at ingestion for both producers. Mask patterns and excluded keywords are also sent to the browser SDK so it can apply them before sending or queueing text. For backend events, redact before posting if the original text must not reach Userpilot; admin masking takes place after the HTTP request arrives. If text capture is off, usage and feedback ratings still work, but text-based AI insights such as topics and frustration analysis are unavailable.