/Docs

Tracking events

An event is a single piece of visitor behaviour you want A vs B to capture — a click on a button, a visit to a page, or a named action your code dispatches. Events are defined once per project and then reused by every metric and feature flag rule that needs them.

Events are the foundation of metrics
Before you can build a metric, the underlying tracking has to exist. Create the event first; the metric tells A vs B how to analyse it.

The three event types

Click events

Click events fire when a visitor clicks an element that matches a CSS selector. Use them for buttons, links, or any interactive element. You can optionally scope a click event to a single page so a button that appears on both the home and product pages can be tracked separately.

Pageview events

Pageview events fire when a visitor reaches a URL. You choose how the URL is matched: a simple substring, an exact match, a path-only check, a pattern with wildcards, or a regular expression. Use pageviews for funnel steps, landing pages, and any "the visitor reached this screen" signal.

Custom events

Custom events fire when your own code calls avsb.track('your-event-key'). They are the right choice when the action happens server-side, after a delay, or anywhere a click or pageview can't observe it directly — a successful purchase, a form validation pass, an in-app upgrade. Custom events can optionally carry a numeric value (revenue, duration, item count) which lets you analyse them with value-based measures later.

Events vs metrics

Events describe what happened. Metrics describe how to analyse what happened. The same Click event on your signup button can power three different metrics in parallel — one counting unique visitors who clicked, one counting the total clicks, and a third measuring revenue per visitor. You only need to define the event once.

Archive vs delete

Archive an event when it is no longer used by new experiments but old data should remain interpretable. Archived events stay in the platform, can be unarchived at any time, and continue to back any sealed analysis plans that referenced them. Delete an event only when nothing references it — A vs B will refuse the delete if any metric still points at the event.

Where to go next