Flagsmith for Unity

Experimentation

Flagsmith Experimentation compares the variants of a multivariate flag against a metric built from events your game sends. The flow:

  1. In the dashboard, create a multivariate flag (for example tutorial_style with variants text and hand), a metric on an event (first_run_complete, aggregated by occurrence) and an experiment that uses both. Start it.
  2. When the player actually sees the variant, call GetExperimentFlag. It returns the flag and records a $flag_exposure event if the player is enrolled.
  3. 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:

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:

Flagsmith experiment completed: hand 19.8 percent ahead of text, over 99 percent chance to be best, 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