Traditional analytics tells you what users clicked. When your product is an AI agent, the interesting behavior happens in layers you can't see from the browser — the reasoning loop, tool calls, token usage, and the decisions the agent made before it said a word.
This accelerator walks you through instrumenting all three tracking layers of an AI-powered chatbot: client-side user interactions, server-side agent orchestration, and agent self-tracking. Each layer answers a different question. Client-side tells you what the user did. Server-side tells you what the agent did. Agent self-tracking tells you what the agent thought — intent interpretation, tool parameter choices, constraint violations, and confidence levels.
You'll work with a fully functional travel booking chatbot built in Next.js with the Vercel AI SDK, supporting Anthropic Claude, OpenAI GPT, and Google Gemini. No Snowplow account is required — the accelerator uses Snowplow Micro running locally in Docker for real-time schema validation.
Use Cases
- Agent performance monitoring — track how long agent responses take, which tools get called most often, and how many LLM steps each request consumes
- Failure and fallback analysis — capture constraint violations and low-confidence intent detections to understand where agents fail to meet user request
- Token and cost attribution — correlate agent_completion token counts with individual agent_step events to identify which reasoning paths drive cost
- User behavior analysis — measure messages per session, response latency, and conversation depth alongside agent-side data in the same event stream
- Agent reasoning audit — trace the full decision path for any response, from user message through intent detection, tool selection, and final completion
Infrastructure Overview
- Snowplow Browser Tracker — captures client-side events (message_sent, message_received) with message_context entity, keyed to a session_id stored in localStorage
- Snowplow Node.js Tracker — captures server-side orchestration events (agent_invocation, agent_step, tool_execution, agent_completion) from the Next.js /api/chat route
- Vercel AI SDK — handles agent orchestration, tool execution, and LLM streaming; the tracking layer wraps its lifecycle hooks without modifying agent logic
- Snowplow Micro — local Docker pipeline that validates all events against their schemas in real time; no cloud infrastructure required to run the accelerator
- Iglu Central schemas — ten event schemas and three entities covering the generic agent lifecycle (invocation, step, tool_execution, completion, and more), available out of the box
- Custom entities — three travel-specific entities (extracted_intent, tool_parameters, tool_results) created during the accelerator to demonstrate domain-specific schema design
Additional Insights
Every event in the system connects through two shared identifiers: session_id (per browser session) and invocation_id (per API request).
This means you can start from any event and trace outward — from a constraint_violation back to the original user_intent_detected, or from a slow message_received forward to the specific tool_execution that caused the latency.
The accelerator supports both a code-along path (write the tracking from scratch) and a read-along path (check out git tags and study the architecture), making it suitable for developers and data architects alike.