# Experiments

> Run A/B tests on game settings with consistent player assignment, then read retention, conversion and session results with significance tests.

An experiment splits players between two to six variants, each of which can carry its own configuration values, such as a different starting balance. Your game asks the SDK which variant a player is in and applies it. Bloxlytics then compares what each group went on to do.

This page covers setting up and reading experiments in the dashboard. For the game side, `GetVariant` and how to apply config values, see [experiments in the SDK](https://docs.bloxlytics.app/sdk/experiments).

Experiments need the Luau SDK. Anyone with **View analytics** can see experiments and results. Creating, editing, starting, stopping and deleting them needs **Create funnels, segments, dashboards, experiments and alerts** (`analytics.configure`).

## Create an experiment

Open **Experiments** in the project sidebar and select **New experiment**.

| Field | Rules |
| --- | --- |
| **Name** | Up to 80 characters, such as "Starting currency" |
| **Key** | What your game passes to `GetVariant`. Starts with a letter; 2 to 48 letters, numbers, `-` and `_`. Unique in the project and can't be changed after creation. |
| **Description** | Optional, up to 500 characters: what you're testing and what you expect |
| **Allocation** | 1 to 100% of players. Players outside the allocation keep the default experience and aren't counted. |
| **Variants** | 2 to 6. See below. |
| **Start** and **End** | Optional, in your local time. Players are assigned from **Start** once the experiment is running, and assignment stops automatically after **End**. |

A new experiment starts with allocation at 100% and two variants: `A` (**Control**) and `B` (**Variant B**), weighted 50 each.

### Variants and weights

Each variant has:

- **Key**: 1 to 32 letters, numbers, `-` and `_`, unique within the experiment. `GetVariant` returns it.
- **Name**: up to 64 characters. The first variant is always the **control** that the others are compared with.
- **Weight**: a whole number from 1 to 100. A variant's share of allocated players is its weight divided by the total of all weights, shown next to the field (**Weight · 50%**). Weights don't need to add up to 100: weights of 1, 1 and 2 give 25%, 25% and 50%.
- **Config sent to the game**: optional values, each with a key (up to 40 characters), a type (**Text**, **Number** or **Boolean**) and a value (up to 256 characters). Select **Add value** to add one. With no values, the game can branch on the variant key alone.

```text Example
Variant A · Control   weight 50   StartingCoins = 100
Variant B · Generous  weight 50   StartingCoins = 500
```

## Lifecycle

An experiment is always in one of three states:

| Status | Game servers | What you can change |
| --- | --- | --- |
| **Draft** | Not sent; `GetVariant` returns `nil` | Everything except the key |
| **Running** | Sent to servers, which assign players | Name, description, config values, start and end. Not variants, weights or allocation. |
| **Stopped** | Not sent; `GetVariant` returns `nil` | Everything except the key |

The buttons on an experiment's page move it between states:

- **Start** (or **Restart** once stopped) sets it running. If no start time was set, it becomes now. Game servers pick up running experiments within five minutes, because the SDK refreshes its configuration every five minutes.
- **Stop** stops new assignments and sets the end time to now. Players already exposed keep their recorded results, and the game falls back to its default experience.
- **Move to draft** (from stopped) makes it fully editable again. Exposure data is kept.

A running experiment is only sent to servers between its **Start** and **End** times.

> **Warning:** Stopping an experiment sets its **End** to the moment you stopped it. If you **Restart** it later, first edit it and clear or move **End**. Otherwise its end time is already in the past and servers won't assign anyone.

Variants, weights and allocation are locked while an experiment runs because changing them would move players between variants mid-test. Saving such a change is refused with "Stop the experiment before changing variants, weights or allocation." Config values aren't locked, so you can correct a value while it runs, but any change affects players already in the test.

Deleting an experiment stops servers assigning players within five minutes. Exposure events already recorded stay in your analytics.

## How players are assigned

Assignment is deterministic: it's calculated from the experiment key and the player's user ID, never stored, and gives the same answer in Bloxlytics and on every game server.

1. **Allocation.** The 32-bit FNV-1a hash of `<experiment key>:<user id>` is taken modulo 10,000. The player is in the experiment if the result is below allocation × 100, so 25% allocation admits buckets 0 to 2,499.
2. **Variant.** A second hash, of `<experiment key>:variant:<user id>`, is taken modulo the total weight. Walking the variants in order and adding up their weights, the player gets the first variant whose running total exceeds that number.

What this means in practice:

- A player lands in the same variant on every server and every visit, with no saved state.
- Each experiment's key is part of the hash, so assignments in different experiments are independent of one another.
- Two experiments with the same variants but different keys split players differently.
- Changing weights or the order of variants would reassign players. That's why they're locked while running.

## Exposure

A player only counts towards results once your game calls `GetVariant` for them and gets a variant back. The SDK then records an `$experiment_exposure` event, at most once per experiment per session. Players outside the allocation, and players your game never asks about, aren't counted.

If a player somehow has exposures for more than one variant, they're counted in the variant of their first exposure. Every result below only counts what happened after that first exposure.

## Reading the results

An experiment's page shows its allocation, start and end, and total players exposed. The **Results** table has one column per variant, with the control first:

| Row | Meaning | Test |
| --- | --- | --- |
| **Players exposed** | Players assigned to the variant | — |
| **D1 retention** | Share of exposed players who played again the day after their first exposure | Two-proportion z-test |
| **Purchase conversion** | Share of exposed players with a completed purchase after exposure | Two-proportion z-test |
| **Average session** | Mean completed session length after exposure: each player's average, averaged across players | Welch's test |
| **Progression completions** | Average `$progression` completions per player after exposure | Not tested |
| **Revenue** | Robux from completed purchases after exposure | Not tested |

D1 retention only counts players whose day after first exposure has finished. When some players are too recent, the cell says how many are "old enough to measure".

Each non-control variant shows its relative change from the control, and a badge for each tested row:

| Badge | Meaning |
| --- | --- |
| **Statistically significant · p = …** | p is below 0.05 and both groups have at least 100 players |
| **Observed difference only · p = …** | Both groups are large enough, but p is 0.05 or more: the gap could plausibly be chance |
| **Not enough data** | Fewer than 100 players in either group, or no data to test |

The change is coloured green or red only when it's significant. Otherwise it stays grey.

### The significance tests

For retention and conversion, each variant is compared with the control using a two-sided two-proportion z-test. With control rate p₁ from n₁ players and variant rate p₂ from n₂:

```text
pooled  p = (x₁ + x₂) / (n₁ + n₂)
SE        = √( p · (1 − p) · (1/n₁ + 1/n₂) )
z         = (p₂ − p₁) / SE
p-value   = 2 · (1 − Φ(|z|))
```

Session length uses Welch's test on the two means and standard deviations, read against the normal distribution (accurate for groups this size). The 100-player minimum applies to each group being compared; for D1 retention, that's players old enough to measure.

### Worked example

You test a generous starting balance. After a week:

| | Control (A) | Variant B |
| --- | --- | --- |
| Players old enough for D1 | 1,000 | 1,000 |
| Returned the next day | 300 | 340 |
| D1 retention | 30.0% | 34.0% |

B shows +13.3% relative to control. The pooled rate is 32%, z ≈ 1.92 and p ≈ 0.055, so the badge reads **Observed difference only**. The result is promising but not yet conclusive.

If the same rates held with 2,000 eligible players in each group, z ≈ 2.71 and p ≈ 0.007: **Statistically significant**.

> **Tip:** Decide how long to run before you start, and judge the result then. Each variant is tested separately against the control, and nothing adjusts for checking the results repeatedly or for testing many variants at once. With five variants, one may cross p < 0.05 by chance alone.

## Using it in your game

The **Use it in your game** section shows a snippet with your experiment's key, ready to copy:

```luau ServerScriptService/Experiments.server.luau
local Analytics = require(game.ServerScriptService.Analytics)

game.Players.PlayerAdded:Connect(function(player)
	local variant, config = Analytics:GetVariant(player, "<experiment key>")
	if variant then
		-- apply the variant's settings for this player
	end
end)
```

`GetVariant` returns `nil` until the experiment is running, outside its start and end times, and for players outside the allocation, so always keep a default path. See [experiments in the SDK](https://docs.bloxlytics.app/sdk/experiments) for the full reference.

## Things to know

- Results use the same SDK data as the rest of the app: sessions, completed purchases and progression events. Purchases the SDK doesn't see don't count towards conversion. See [purchases](https://docs.bloxlytics.app/sdk/purchases).
- Revenue and progression completions are shown for context but aren't significance-tested.
- For game-wide settings that aren't a test, use [remote configuration](https://docs.bloxlytics.app/sdk/remote-config) instead.
