Experimentation
Flagsmith Experimentation compares the variants of a multivariate flag against a metric built from events your game sends. The flow:
- In the dashboard, create a multivariate flag (for example
tutorial_stylewith variantstextandhand), a metric on an event (first_run_complete, aggregated by occurrence) and an experiment that uses both. Start it. - When the player actually sees the variant, call
GetExperimentFlag. It returns the flag and records a$flag_exposureevent if the player is enrolled. - When the outcome happens, call
TrackEvent.
var tutorial = flagsmith.GetExperimentFlag("tutorial_style");
ShowTutorial(tutorial?.Value ?? "text");
...
flagsmith.TrackEvent("first_run_complete", distance, new Dictionary<string, object> { ["level"] = 1 });
Details that matter for clean results:
- Call
GetExperimentFlagat the moment of exposure, not at startup. A player who never opens the shop shouldn't count as exposed to the shop experiment. - Calling it again is harmless. A duplicate exposure (same flag, identity, variant and experiment) is dropped for the rest of the session.
- No exposure is recorded when the flag is off, the identity isn't enrolled, or there is no running experiment on the flag.
- Event names starting with
$are reserved, andTrackEventthrows for them. valueis sent as text (numbers with the invariant culture).metadatais any JSON-serialisable dictionary. The client addssdk_version.
After enough players, the experiment's page in Flagsmith shows the result. Here the rule (ship at 95% chance to be best with 200+ players per arm) was fixed before the second batch of players, it passed, and the experiment was completed with hand rolled out to everyone:

Self-hosted Flagsmith after server/simulate.py sent 800 synthetic players through the demo experiment. The lift is simulated on purpose to show the loop working; it says nothing about real players.
Delivery
Events wait in a queue and are sent every Flush Seconds, and also when the app is paused, loses focus or quits. Before sending on pause and quit, the queue is written to disk, so an app the OS kills in the background sends its events on the next launch.
| Situation | What happens |
|---|---|
| Network error or HTTP 5xx | Retried once, then the batch goes back in the queue for the next flush |
| HTTP 4xx | The batch is dropped and an error is logged (retrying would fail the same way) |
| Queue over 10,000 events | The oldest are dropped |
| Event older than 10 days | Dropped before sending (the API rejects it) |
| Batch over 2 MiB | Split into several requests |