Vexil/Docs/Tracking events
Dashboard

Tracking events

Power your A/B experiments by recording which variant each user sees and whether they converted.

Recording an impression

Call ff.impression() right after evaluating a flag that's part of an experiment. This tells Vexil which variant the user was shown.

ts
const variant = await ff.evaluate<string>('hero-cta', { userId })

await ff.impression('hero-cta-experiment-id', {
  userId,
  variantValue: variant,   // the value the user actually saw
})

Recording a conversion

Call ff.track() when the user completes the goal action. The event name must exactly match the goal event you entered when creating the experiment.

ts
// User successfully signed up
await ff.track('signup', { userId })
Always call ff.impression() before ff.track() in the same user session. Conversions are automatically matched to the most recent impression for that user.

Complete example

ts
// On page load — evaluate and record impression
const ctaText = await ff.evaluate<string>('hero-cta', { userId })
await ff.impression('hero-cta-experiment-id', { userId, variantValue: ctaText })

// Render the CTA with ctaText
renderButton(ctaText)

// When user clicks the button and completes sign-up
onSignupComplete(() => {
  ff.track('signup', { userId })
})
← PreviousEvaluating flagsNext →SDK reference