AppFig Start free
  1. Home
  2. Guides
  3. How to A/B test level difficulty in a mobile game

How to A/B test level difficulty in a mobile game

Put the difficulty numbers behind remote config, give a random half of struggling players an easier version, and compare completion, retention and revenue.

To A/B test level difficulty, make the numbers that define difficulty readable at run time, split players at random into groups that get different numbers, and compare level completion, retention and revenue per player between the groups. With AppFig the split happens on the device, each device keeps its group, and the audience can be limited to the players the change is meant for, such as those who failed a level three times.

The code below is Unity; the same steps work with the Android, iOS and Flutter SDKs.

What to make changeable

Difficulty is rarely one number. Pick the one or two that designers already argue about and leave the rest in code.

Value Example What it changes
Difficulty multiplier 1.0, 0.8 Enemy health, speed or score targets, scaled together
Moves or time allowed 25 moves, 90 seconds How tight a puzzle level is
Lives 3, 5 How many attempts a session allows
Hint or booster after N fails after 3 fails When the game offers help

An AppFig experiment can change up to five values at once, and every player in a variant gets that variant for all of them, so a multiplier and a move count can be tested as one package (Experiments).

Step 1: Read the value where the level loads

Replace the constant with a lookup and keep today's number as the fallback. This is the pattern from the Unity guide:

public void LoadLevel(int levelNumber)
{
    // Check feature right before using it
    string difficultyValue = AppFig.GetFeatureValue("difficulty_multiplier");
    float difficulty = float.Parse(difficultyValue ?? "1.0");

    // Apply immediately
    ApplyDifficultySettings(difficulty);
    LoadScene(levelNumber);
}

GetFeatureValue returns null when no rule matches, so the ?? "1.0" is what keeps the game unchanged for everyone outside the test. Read the value once when the level loads, not in Update(), so a level never changes difficulty halfway through.

Step 2: Log the events the test needs

Rules and results both depend on events. Log a completion and a failure when they happen:

AppFig.LogEvent("level_complete", new Dictionary<string, string> {
    { "level_number", currentLevel.ToString() },
    { "time_seconds", elapsedTime.ToString() }
});

AppFig.LogEvent("level_failed", new Dictionary<string, string> {
    { "level_number", currentLevel.ToString() }
});

AppFig reads experiment results from your own Google Analytics, so the success event has to reach Google Analytics too. If you already log level_complete there, you are done; otherwise log it in both places.

Ship this build once. Until it is live, nothing in the dashboard can affect the game, because no installed version reads the value.

Step 3: Target players who failed several times

Easier levels for everyone is a different test from easier levels for players who are stuck. The second is usually the one worth running, and it needs a rule that looks at what the player has done. AppFig evaluates rules on the device against the events your game logged, so this audience needs no server and no export:

{
  "conditions": {
    "events": {
      "mode": "simple",
      "operator": "AND",
      "items": [
        {
          "key": "level_failed",
          "count": { "operator": ">=", "value": 3 },
          "within_last_days": 7
        }
      ]
    },
    "user_properties": [],
    "user_properties_operator": "AND",
    "device": [],
    "device_operator": "AND"
  }
}

An item can also match on event parameters with param; the rule schema lists every operator.

Two details matter here:

Step 4: Build the experiment

In the dashboard, open Menu → Experiments and fill in:

Saving writes a draft. The experiment starts when you publish, and you should publish only after the release from step 2 is live in the stores.

Assignment needs no user id: a device without one is assigned by its device id, and the assignment is stored on the device, so a player does not flip between difficulties across restarts.

What to measure

Completion. Choose "more users who do an event" with level_complete as the success event. AppFig compares the share of each group's players who sent it.

Retention. The SDK sets a user property af_<experiment key> in your analytics tool with the variant name. Use it to split the retention report in Google Analytics by variant. Look at it even if completion decides the winner.

Revenue. Easier levels can reduce what players spend on boosters and continues, and can change how many ads they watch. Choose "more revenue per user" if that is the risk you care about most. Revenue here is Google Analytics' total revenue: purchase events with a value and currency, and ad_impression events with a value.

How AppFig calls a winner

For more users who do an event:

For more revenue per user:

A worked example, with invented numbers

A puzzle game sees players leave around level 12. The team tests difficulty_multiplier at 0.8 for players with three or more failures in the last 7 days.

Control (1.0) Easier (0.8)
Players in the group 2,400 2,380
Sent level_complete afterwards 1,010 (42.1%) 1,240 (52.1%)
Revenue per player $0.21 $0.20

Both groups are well past 100 users and 10 conversions, and a ten-point gap at this size is far outside chance. Revenue per player is about 5% lower, right at the edge of the guard, so the team splits the Google Analytics retention report by af_<experiment key> before deciding. Day-7 retention is higher in the easier group, so they press Roll out, which writes the variant's value for the audience as a plain rule in the draft, and publish. No release was involved after the first one.

Mistakes to avoid

FAQ

How many players do I need to A/B test difficulty?

AppFig needs at least 100 users and 10 conversions in every group before it will call a conversion winner, and 100 users per group plus 7 days with revenue for a revenue winner. Those are minimums; small differences need more players.

Can I make levels easier only for players who keep failing?

Yes. A rule can count an event such as level_failed over a recent window and match only players above a threshold. The rule is evaluated on the device, so it takes effect as soon as the player's own events satisfy it.

Will a player see different difficulty each time they open the game?

No. Once a device has a variant it keeps it across restarts, sign-in and sign-out, and even if you change the weights later. Reinstalling the app creates a new device id, so a device without a user id may land in a different variant.

Can I test several difficulty values at once?

Yes, an experiment holds up to 5 values and up to 10 variants, and each player gets the same variant for every value. The free Lite plan runs one A/B test at a time; see pricing.

Keep reading