Experiments (A/B tests)

An experiment splits people between two or more variants of something in your app and measures which one gets more of them to do a goal event, such as checkout_completed. Create experiments under Experiments; your app asks the SDK which variant to show.

1. Create the experiment

  • Name and key — The key (for example checkout-cta-color) is what your code passes to the SDK. It cannot change once the experiment exists.
  • Environment — Production, staging or development. Only apps initialized with the same environment get variants; the SDK defaults to production.
  • Primary success metric — The event that counts as a conversion. It must be an event your app already tracks.
  • Variants and traffic split — At least two variants with weights that add up to 100. One is the control, the version you have today.

New experiments start as drafts. Click Start Experiment on its page when your code is deployed. Until then, and after it is paused or completed, every person gets the control.

2. Show the variant in your app

ts
import { traceiq } from 'traceiq-sdk-js';

const { variantKey, isEligible } = await traceiq.experiments.getVariant('checkout-cta-color');

if (variantKey === 'variant_b') {
  renderHighContrastButton();
} else {
  renderCurrentButton(); // control, or the experiment isn't running
}

Call identify() first when you know who the person is, so the same person sees the same variant on every device. Assignment is deterministic: TraceIQ hashes the experiment and the person's id, so asking again always returns the same variant.

getVariant() records an exposure for the person the first time it returns a variant. Only exposed people count in the results. If you fetch the variant early but show it later, pass { trackExposure: false } and call traceiq.experiments.recordExposure(key, variantKey) at the moment it is on screen.

Experiments are built into the browser SDK. From other platforms, call the HTTP API with your write key: POST /v1/experiments/evaluate with projectId, experimentKey and distinctId, then POST /v1/experiments/exposure with the returned variantKey.

3. Read the results

  • Conversion — A person converts when they send the goal event after their exposure. Each person counts once.
  • Uplift — How much higher or lower each variant’s conversion rate is than the control’s.
  • Significance — Once both the control and a variant have at least 30 exposed people, TraceIQ runs a two-tailed z-test. Below p = 0.05 the difference is marked significant; until then it shows as collecting or not significant.
  • Finishing — Use Complete & Declare Winner to stop the experiment and record which variant won, then ship that variant to everyone in code.

Need a plain on/off rollout rather than a comparison? Use feature flags.