A/B Testing Reference
AppFig extends its rule engine with a lightweight, device-side multivariate testing (A/B testing) mode. It reuses the existing targeting system (events, sequences, user properties, device conditions) — there is no separate "experiment" concept to learn.
Overview
A/B testing in AppFig:
- Assigns users to experiment variants deterministically, with zero network calls at evaluation time
- Persists the assignment on the device so nobody flips to a different variant in the middle of a test
- Works with or without a user id: a device without one is assigned by its device id
- Reports each assignment to your analytics tool as a user property per experiment and a one-time assignment event
This is not a separate rule type. It's a toggle on the Return Value section of an existing rule — all targeting logic (who the rule applies to) stays exactly the same whether the rule returns a static value or an A/B test.
Data Model
Each rule already has a conditions block (see Rule Schema) that decides who the rule applies to. What changes is the return side — a rule returns either:
{ "value": any }
or
{
"ab_test": {
"experiment_key": "string",
"variants": [
{ "name": "string", "weight": number, "value": any }
]
}
}
A rule never has both value and ab_test — the dashboard toggle decides which one a rule stores.
Fields:
experiment_key(required) - Unique identifier for the experiment. Used in analytics and for deterministic assignment.variants(required) - Array of possible outcomes for users who match this rule's conditions.name(required) - Variant identifier, e.g."control","treatment"weight(required) - Relative weight for probabilistic assignment. Weights don't need to sum to 100 — they're normalized (e.g.1/1and50/50produce the same 50/50 split).value(required) - WhatgetFeatureValue()/getConfig()returns for a user assigned to this variant. Can be any JSON-serializable type, same as a normal rule'svalue.
Example: 50/50 button color test
{
"checkout_button_color": [
{
"conditions": {
"events": { "mode": "simple", "operator": "AND", "items": [] },
"user_properties": [],
"user_properties_operator": "AND",
"device": [],
"device_operator": "AND"
},
"ab_test": {
"experiment_key": "checkout_button_color_test",
"variants": [
{ "name": "control", "weight": 1, "value": "blue" },
{ "name": "treatment", "weight": 1, "value": "green" }
]
}
}
]
}
Example: Weighted rollout (10% treatment)
{
"new_onboarding_flow": [
{
"conditions": {
"events": { "mode": "simple", "operator": "AND", "items": [] },
"user_properties": [],
"user_properties_operator": "AND",
"device": [],
"device_operator": "AND"
},
"ab_test": {
"experiment_key": "onboarding_v2_rollout",
"variants": [
{ "name": "control", "weight": 90, "value": "legacy" },
{ "name": "treatment", "weight": 10, "value": "v2" }
]
}
}
]
}
Dashboard: Toggle-Based A/B Test Mode
In the dashboard rule builder, the condition builder (events, user properties, device) is untouched — A/B testing only changes the Return Value section:
- Toggle OFF (default) - Single value input, same as any normal rule
- Toggle ON (
Run as A/B Test) - Replaces the value input with:- An experiment key field
- A variants table (name, weight, value per row)
This keeps targeting logic unified: you build your conditions once, and can flip a rule between "static value" and "A/B test" without redoing any targeting.
Assignment Behavior
Describes SDK 2.1.0 and later. Differences from earlier versions are listed at the end of this section.
When a rule with an A/B test matches, the SDK decides the variant in this order:
- An assignment stored on the device wins. Once a device has a variant for an
experiment_key, it keeps it: across app restarts, after sign-in, after sign-out, and when you change the weights. - Otherwise the user id is hashed, if one is set. The same user id and
experiment_keygive the same variant on every device and every platform. - Otherwise the device id is hashed. The SDK creates this id on first launch and keeps it on the device. Apps without sign-in need nothing else.
Assignment needs no network call, and it only happens when the rule's conditions match: a user who does not meet the conditions is not in the experiment and is not reported as part of it.
What follows from this:
- A user id is optional. Set one if a signed-in person should get the same variant on all their devices. To get that, set it before the SDK starts (before
init); an experiment the device entered before the id was known keeps its device assignment. - Changing weights affects only new assignments. Devices already in the experiment keep their variant.
- Removing a variant moves the devices that had it to a fresh assignment among the remaining variants.
- Changing the conditions can take a user out of the experiment (the rule no longer matches them). If they match again later, they get the variant they had.
- Reinstalling the app creates a new device id, so a device without a user id may land in a different variant.
- No experiment lifecycle on AppFig: AppFig does not track start and end dates, statistical significance or winners. It assigns and remembers variants; you analyze the experiment in your analytics tool.
Typical workflow: toggle a rule's Return Value to A/B Test → users start getting variants → you analyze results in your analytics tool → once you have a winner, toggle back to a static value and write the winning value directly.
Before SDK 2.1.0: a device without a user id always received the first variant and was not counted in the experiment; assignments were kept for the session only; and calling setUserId assigned the device again.
Analytics Integration
The SDK reports assignments to the analytics tool you connect. It is the same whether the device was assigned by user id or by device id.
A user property per experiment
- Name:
af_followed by the experiment key. Characters other than letters, digits and_become_, and the name is cut at 24 characters (the Google Analytics limit).limit_testbecomesaf_limit_test. - Value: the variant name. It is cleared when the experiment is no longer in your rules.
Use it to segment any report or build an audience by variant.
An assignment event, once per device and experiment
Sent when the device enters the experiment, and not again on later app starts:
| Tool | Event | Properties |
|---|---|---|
| Firebase / Google Analytics | appfig_experiment |
experiment, variant |
| Mixpanel | $experiment_started |
Experiment name, Variant name |
| Amplitude | $exposure |
flag_key, variant |
Use it as the starting point when you measure what users did after entering the experiment.
In SDK 2.1.0 the Firebase / Google Analytics event was named appfig_experiment_assigned with the parameter experiment_key. From 2.2.0 it is appfig_experiment with experiment.
A feature event, for every feature the app reads (SDK 2.2.0 and later)
Experiments are not the only thing worth seeing in analytics. When your app reads a feature, the SDK sends appfig_feature with two parameters:
| Parameter | Value |
|---|---|
feature |
The feature's name |
feature_value |
The value this device received, as text (cut at 100 characters) |
It is sent once per device for each feature and value, and again only when the value this device gets changes. A feature the app never reads sends nothing. The event has the same name in every analytics tool.
Use it to count how many users received a value after you changed it. In Google Analytics, register feature and feature_value (and experiment, variant) once as event-scoped custom dimensions; that covers every feature and experiment you add later.
The combined property
appfig_experiments is still set, as pipe-separated experiment_key:variant_name pairs:
"checkout_button_color_test:treatment|onboarding_v2_rollout:control"
Prefer the per-experiment properties: with several experiments running, the combined value exceeds the 36-character limit Google Analytics puts on user property values.
Connecting a tool
Firebase, Mixpanel and Amplitude have ready-made providers in the Unity, Android, iOS and React SDKs. Register one at startup:
AppFig.RegisterAnalyticsProvider(new FirebaseProvider(analytics));
For any other tool, implement the provider interface. The assignment event method is optional:
class MyProvider implements IAnalyticsProvider {
setUserProperty(key: string, value: string) {
myAnalytics.setUserProperty(key, value);
}
trackExperimentAssigned(experimentKey: string, variantName: string) {
myAnalytics.track('experiment_assigned', { experiment: experimentKey, variant: variantName });
}
}
AppFig.RegisterAnalyticsProvider(new MyProvider());
In Flutter, pass two callbacks:
AppFig.connectAnalytics(
setUserProperty: (name, value) =>
FirebaseAnalytics.instance.setUserProperty(name: name, value: value.isEmpty ? null : value),
logEvent: (name, parameters) =>
FirebaseAnalytics.instance.logEvent(name: name, parameters: parameters),
);
A provider can be registered before or after the SDK starts; assignments made earlier are delivered when it is registered.
BigQuery needs no provider. With the Firebase provider connected and the Google Analytics BigQuery export turned on, the event and the properties arrive in your own BigQuery project.
AppFig itself receives none of this data: assignments go from the device to your analytics tool.
Next Steps
- Experiments - Test up to five values with one audience, and how results are measured
- Rule Schema Reference - Full targeting condition reference (applies identically to A/B test rules)
- Rule Prioritization - Control which RuleSet (static or A/B test) wins when several could match
- Testing Guide - Test your rules