A/B Experimentation
FeatureSignals has built-in A/B experimentation support. Create flags with the ab type to assign users to weighted variants using consistent hashing.
Concepts
| Term | Description |
|---|---|
| Variant | One arm of an experiment with a key, value, and weight |
| Weight | Relative proportion in basis points (must sum to 10000) |
| Impression | A record of a user seeing a specific variant |
Configuring Variants
bash
curl -X PUT https://api.featuresignals.com/v1/projects/$PROJECT_ID/flags/checkout-experiment/environments/$ENV_ID \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"enabled": true,
"variants": [
{"key": "control", "value": "original-checkout", "weight": 5000},
{"key": "treatment-a", "value": "streamlined-checkout", "weight": 3000},
{"key": "treatment-b", "value": "one-click-checkout", "weight": 2000}
]
}'How Assignment Works
- A hash bucket is computed from
flagKey + "." + userKey(0–9999) - Variants are walked in order, accumulating weights
- The first variant where
bucket < cumulative_weightis assigned
Evaluating Variants
typescript
const variant = client.stringVariation(
'checkout-experiment',
{ key: 'user-123' },
'control'
);
// → "streamlined-checkout" or "original-checkout" or "one-click-checkout"Tracking Impressions
bash
curl -X POST https://api.featuresignals.com/v1/track \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"flag_key": "checkout-experiment",
"variant_key": "treatment-a",
"user_key": "user-123"
}'