Skip to main content
By the end of this guide, your web app sends a checkout-completed event to Confidence, Confidence stores it, and you can build metrics on it. Events are the main way to record data for Confidence Cloud. Event tracking has two parts:
  1. Send events to Confidence. Your app calls track on a Confidence SDK.
  2. Set up an event schema. Confidence stores an event only when an event definition with a matching name and schema exists.
You can define the schema in advance, or send events first and then review and create the event from the schema that Confidence detects. After you create the event, Confidence records the events. The guide has these steps:
  1. Define the event schema, or skip this step and create the event later.
  2. Send events from your app.
  3. Create the event and verify arrival.
  4. Use events in metrics.
Each step shows how to do it with AI first, then in the Confidence app.
Do it with AI. Connect the Confidence MCP servers to your AI assistant, then set up the event with one prompt:

Before You Begin

Define the Event Schema

An event definition names an event type and describes its payload with a schema. The event name in track must match the definition name. Names use lowercase letters, digits, and hyphens, and are 4 to 63 characters long. Define checkout-completed with these fields:
  • context.targeting_key: a string that identifies the user, with semantic type Entity
  • value: a number
  • currency: a string
  • item_count: an integer
Every event needs at least one entity field. Without one, Confidence generates no fact table for the event. To skip this step, send the event first and create it from the detected schema in Create the Event and Verify Arrival.
The assistant uses the Flags MCP tool createEventDefinition. To check existing definitions first, it uses listEventDefinitions.

Send Events from Your App

Call track on the same OpenFeature client that you use for flags. Tracking requires @openfeature/web-sdk 1.3.0 or later and @spotify-confidence/openfeature-web-provider 0.3.22 or later.
The provider adds the evaluation context under a context field and renames targetingKey to targeting_key. The tracking details become top-level fields. See Event payload. track returns immediately and doesn’t report whether Confidence accepted the event. The SDK queues events in memory and sends them in batches. See Batches and delivery. For Swift, Kotlin, and Flutter examples, see Track events.

Create the Event and Verify Arrival

If you skipped the schema step, Confidence rejects the events, detects a schema from the payload, and lists the event in the Events table as Sent but not stored. Create the event so that Confidence stores events of this type from then on.
The assistant uses the Flags MCP tool queryEventsUsage, which returns hourly publish and validation failure counts for the last 1 to 7 days. getEventDefinition returns the schema and publish count.No MCP tool creates an event from a detected schema. To create the event with AI, ask the assistant to call createEventDefinition with the full schema. To add fields to an existing event, it uses updateEventDefinition. You can’t change the type of an existing field.
Watch for these problems:
  • Missing fields. Confidence drops fields that aren’t in the schema, and the event page shows a warning. Click Update in the warning to add the fields. Confidence doesn’t recover values it dropped before the update.
  • Validation failures. Confidence rejects events with wrong field types. You can’t change a field’s type after you save it. Create a new event definition instead.

Use Events in Metrics

On Confidence Cloud, Confidence creates a fact table for each event that references an entity. Numeric fields become measurements, and other fields become dimensions. Build a metric on the fact table with Create your first metric. On Warehouse Native, also create an event connection so that Confidence writes event data to your warehouse. The Flags MCP tool createEventConnection creates it. See Event connectors.