Segment Priority and Order in Flagsmith

Segment Priority and Order in Flagsmith

A complete, plain-English guide to what happens when one user belongs to many groups at once: how Flagsmith decides which setting wins, how to order segment overrides on purpose, and how to test, review and maintain that order as your product grows.

Picture a cinema that gives discounts. Students pay half price, seniors pay a third less, and members of the film club get in free. On a quiet Tuesday, a retired teacher who also studies part-time and belongs to the film club walks up to the counter. Which discount should the cashier apply? If the cashier has no clear rule, every cashier will answer differently, and customers will argue. If the cinema has a written, ranked list, the cashier simply reads from the top and stops at the first discount that fits.

Flagsmith faces the same question every time a user qualifies for more than one special setting. Flagsmith is a tool that lets software teams switch features on and off, and change their values, without shipping new code. The switches are called feature flags. Groups of users, called segments, can be given their own settings for a flag. When a person belongs to several of those groups, Flagsmith needs a tie-breaker. That tie-breaker is segment priority, also called segment order.

In this guide you will learn what priority means, where it lives, how Flagsmith walks down the list, how to choose a sensible order, how to change it safely, how to test it, and how real systems outside Flagsmith use the same idea. Everything is explained step by step, with everyday comparisons and examples.

i
Before you start

Flagsmith changes over time. Dashboard labels, where a new override lands in the list, behaviour with versioned features and the exact controls for reordering can differ between versions and plans. Treat this guide as the mental model, and confirm fine details in the official Flagsmith documentation and in your own account.

1Why Order Matters

Order is invisible when everything is simple, and decisive when it is not.

The simple world

In a small product, one flag might have one special group. Staff see the new page, everyone else does not. There is nothing to rank, because nobody can be in two places at once. Teams in this world rarely think about priority at all.

The crowded world

Products grow. Soon the same flag has special settings for staff, for premium customers, for people in one country, for users of an old app version and for a pilot customer. Real people fit into many of these groups at the same time. A premium customer in India using an old app version belongs to three groups. If each group wants a different value, only one value can be used. Something must choose.

What goes wrong without a clear order

  • Surprise values. A user sees a setting that nobody expected, and nobody can explain why.
  • Silent swallowing. A broad group placed too high swallows a narrow group below it, so the narrow group’s special setting never applies.
  • Broken promises. A pilot customer is promised a higher limit, but a general rule above it overrides the promise.
  • Unsafe launches. A safety switch for one browser is hidden behind a friendlier rule that matches first.
  • Fear of change. Teams stop adding new groups because they cannot predict what will happen.
Analogy

Think of a set of road signs on one street. One sign says “50 kilometres per hour”. A newer sign near the school says “30”. Drivers obey the nearest, most specific sign. If the signs were placed in a random order, nobody would know which to follow. Priority is the rule that says which sign wins.

The key idea in one line

Flagsmith looks at the ranked list of segment overrides for a feature, from top to bottom, and uses the first one whose group the user belongs to. Everything else in this guide is about doing that well.

Clarity

Predictable answers

Anyone can work out what a user will receive by reading the list from the top.

Safety

Safety rules stay on top

Switches that protect customers are never hidden behind friendly rules.

Fairness

Specific beats general

Narrow special cases are not swallowed by broad groups.

Speed

Faster debugging

When a user complains, you know where to look first.

Growth

Room to add groups

A clear scheme lets new segments slot in without fear.

Trust

Fewer arguments

Support, product and engineering agree on what should happen.

2A Quick Recap of the Moving Parts

Priority only makes sense once the pieces it orders are clear. Here is a short refresher.

Organisations, projects and environments

Flagsmith organises everything in three layers. An organisation is usually a company or team. Inside it live projects, each normally one product. Inside each project are environments, such as Development, Staging and Production. A feature is a named switch defined once per project. What it does in each environment, whether it is on and what value it carries, is stored separately for each environment.

Identities and traits

An identity is a record standing for one user. A trait is one named fact about that user, such as “plan” or “country”. Traits are the raw material that segment rules look at.

Segments

A segment is a named group defined by rules over traits. “Premium Users” might mean that the trait “plan” equals “premium”. Membership is worked out automatically each time flags are requested. Nobody adds users to a segment by hand. Segment definitions belong to the project, so every environment can see them.

Segment overrides

A segment override connects a segment to a feature in one environment. It says: “For this feature, in this environment, for people in this segment, use this state and this value.” A feature can carry many segment overrides at once, and that is where order comes in.

Identity overrides

An identity override gives one named user a special setting for a feature. It is the most personal kind of setting.

flowchart TD
    PRJ["Project"] --> FEAT["Feature: upload_limit_mb"]
    PRJ --> SEG["Segments: Staff, Premium, India, Old App"]
    PRJ --> ENV["Environment: Production"]
    ENV --> DEF["Environment default value"]
    ENV --> LIST["Ranked list of segment overrides for this feature"]
    LIST --> O1["1: Staff"]
    LIST --> O2["2: Premium"]
    LIST --> O3["3: India"]
    LIST --> O4["4: Old App"]
    ENV --> IDO["Identity overrides for named users"]
Figure 1: The ranked list of segment overrides sits between identity overrides and the default

A map of where things live

ThingLives atDoes it have an order?
FeatureProjectNo
Segment definitionProjectNo. A segment has no rank of its own.
Segment overrideOne feature in one environmentYes. This is what is ranked.
Identity overrideOne feature in one environmentNo. Personal settings come before the list.
Environment defaultOne feature in one environmentNo. It comes after the list.
!
Remember

A segment is not ranked on its own. The same segment can sit high in one feature’s list and low in another’s. Priority belongs to the pairing of a segment with a feature in an environment.

3What Is Segment Priority?

The idea is short. The consequences are long. Let us define it carefully.

A plain definition

Segment priority is the rank that Flagsmith gives each segment override attached to a feature in an environment. When a user qualifies for more than one override, Flagsmith uses the one with the highest rank, meaning the one nearest the top of the list. Lower ones are ignored for that user and that feature.

First match wins

The method is often described as “first match wins”. Flagsmith reads the list from the top. For each entry it asks, “Does this user belong to this segment?” The first time the answer is yes, it stops, takes that entry’s state and value, and ignores the rest. Entries below are never consulted.

Analogy

Imagine a bouncer holding a list of rules on a clipboard, ordered from most important to least. “Staff: let in through the side door. Guests with tickets: front door. Everyone else: wait in the queue.” The bouncer reads down the list and stops at the first rule that fits the person standing there.

What priority is not

  • It is not a score. Nothing is added up. There is no “strongest match”.
  • It is not about how many conditions a segment has. A tiny, simple segment placed first beats a detailed one placed second.
  • It is not the same as the rule logic inside a segment. The words ALL, ANY and NONE decide who is in the segment. Priority decides which segment’s setting is used once many segments say yes.
  • It is not about time. A segment created last year can outrank one created yesterday if it is higher on the list.

Two separate questions

It helps to keep two questions apart. The first is membership: “Is this user in this segment?” That is decided by rules and traits. The second is priority: “Among all the segments this user is in, whose setting do we use?” That is decided by the order of the list. Mixing these two questions up is the most common source of confusion.

QuestionDecided byWhere you change it
Is the user in the segment?Segment rules and the user’s traitsThe segment definition
Which matching segment wins?The order of overrides on the featureThe feature’s segment override list
What value does the winner give?The override’s own state and valueThe override itself
Membership says who qualifies. Priority says whose answer counts.

4Priority Belongs to the Pairing

One of the most important facts about priority is where it is stored. Many mistakes come from misplacing it.

One list per feature per environment

Each feature, in each environment, has its own list of segment overrides, and each list has its own order. If you have ten features and three environments, you may have up to thirty separate lists. Reordering one does not touch the others.

The same segment, different ranks

Consider the segment “Premium Users”. For the feature “upload_limit_mb” it might be second in the list, below Staff. For the feature “show_ads” it might be first, because the business wants premium users to be free of ads before any other rule applies. The segment is the same. The ranks are independent.

flowchart LR
    subgraph F1["Feature: upload_limit_mb in Production"]
    A1["1: Staff"] --> A2["2: Premium"] --> A3["3: India"]
    end
    subgraph F2["Feature: show_ads in Production"]
    B1["1: Premium"] --> B2["2: Staff"] --> B3["3: Old App"]
    end
Figure 2: Two features, each with its own order for overlapping segments

Different environments, different lists

The list for a feature in Staging is separate from the list in Production. It is common for Staging to have extra segments for testing, such as “QA Team”, that do not exist in Production’s list. It is also common for the two lists to drift apart in order, which surprises teams who test in Staging and expect the same behaviour in Production.

Analogy

Each department in a company has its own approval ladder. The finance department may ask the manager first and the director second. The design department may do the opposite. Two departments can use the same people in a different order, and both are right for their own work.

What this means for your habits

  • When you change the order for one feature, remember that other features are unaffected.
  • When you add a new segment, you must place it in each feature’s list where it matters.
  • When you promote a change from Staging to Production, repeat the ordering there on purpose. Do not assume it follows.
  • When you document your scheme, document it per feature, or per family of features.
i
Tip

If many features share the same segments, it is wise to give them the same order wherever possible. Consistency across features makes the whole system easier to remember.

What about segments created for a single feature

Some versions of Flagsmith let you create a segment that is meant for one feature only, sometimes called a feature-specific segment. It still takes part in the same ranked list for that feature. Check how your version handles these, and keep their names clear so that people do not mistake them for project-wide segments.

5How Flagsmith Walks Down the List

Let us follow Flagsmith step by step as it works out the answer for one feature and one user.

The steps

1

Gather the user’s facts

Flagsmith loads the identity and its traits, merging any traits sent with the current request.

2

Check for a personal override

If this exact user has an identity override for the feature, that wins at once, and the walk ends.

3

Start at the top of the segment list

Flagsmith takes the highest-ranked segment override for this feature in this environment.

4

Test membership

It checks whether the user’s traits satisfy that segment’s rules. If yes, that override’s state and value are used, and the walk ends.

5

Move down one step

If the answer was no, Flagsmith moves to the next entry and repeats the test.

6

Fall back to the default

If no entry matched, the environment’s default state and value for the feature are used.

flowchart TD
    START["Request: feature X for user U"] --> Q0{"Identity override for U?"}
    Q0 -- "Yes" --> W0["Use identity override"]
    Q0 -- "No" --> Q1{"U in segment at rank 1?"}
    Q1 -- "Yes" --> W1["Use rank 1 override"]
    Q1 -- "No" --> Q2{"U in segment at rank 2?"}
    Q2 -- "Yes" --> W2["Use rank 2 override"]
    Q2 -- "No" --> Q3{"U in segment at rank 3?"}
    Q3 -- "Yes" --> W3["Use rank 3 override"]
    Q3 -- "No" --> D["Use environment default"]
Figure 3: The walk down the list, stopping at the first match

Why order of testing equals order of authority

Because Flagsmith stops at the first match, the position of an entry is exactly its power. Entry number one can never be overruled by an entry below it. Entry number five can only apply to users who did not match entries one to four.

A worked example

Suppose the list for “upload_limit_mb” is: 1 Staff gives 1000, 2 Premium gives 500, 3 India gives 40, and the default is 25. Priya is a premium customer in India. Flagsmith checks Staff, and Priya is not staff, so no. It checks Premium, and Priya is premium, so yes. It stops and gives 500. The India entry is never even looked at for her. Her friend Dev is a free user in India. Staff, no. Premium, no. India, yes. Dev receives 40. A free user in Brazil matches none and receives 25.

i
Good to know

Flagsmith decides this fresh every time flags are requested. Priority is applied to the user’s latest traits, so if a user’s trait changes, the winner may change on the very next request.

6The Three Layers of Authority

Segment order is the middle layer of a three-layer system. Knowing all three prevents most surprises.

Layer 1: Identity overrides

An identity override is a setting for one named user. It is checked first and beats every segment. Teams use it for one-off cases, such as an executive who wants an early preview, or a customer with a promised exception. Because it beats everything, it is also the easiest way to create confusion if it is forgotten.

Layer 2: Segment overrides, in ranked order

This is the layer this guide is mainly about. The ranked list is read from the top, and the first matching entry wins.

Layer 3: The environment default

If nothing above applied, the user receives the feature’s default state and value for that environment. This is the setting that everyone gets unless something special matches.

flowchart TD
    A["Layer 1: Identity override, one named user"] --> B["Layer 2: Segment overrides in ranked order"]
    B --> C["Layer 3: Environment default"]
    A -. "if none" .-> B
    B -. "if none match" .-> C
Figure 4: Three layers, checked from the most personal to the most general
LayerWho it targetsCheckedTypical use
Identity overrideOne named userFirstPromised exceptions, personal previews
Segment overrideA group defined by rulesSecond, top to bottomPlans, regions, versions, staff
Environment defaultEveryone elseLastThe normal setting for the product
Analogy

A hotel front desk first checks whether you have a personal arrangement with the manager. If not, it checks your membership level, from the highest to the lowest. If you have neither, you get the standard room. Three layers, from most personal to most general.

Why the layers are ordered this way

The more specific the instruction, the more likely it was made on purpose for this case. A personal exception is the most deliberate. A group rule is deliberate for the group. The default is only a starting position. Letting specific instructions beat general ones is a pattern found in many systems, from legal rules to computer firewalls.

!
Watch the top layer

A user with an old identity override will ignore every change you make to segments for that feature. When a user “does not respond” to a change, check for a personal override first.

7Worked Examples

Examples make the idea stick. Here are several, from simple to subtle.

Example 1: Plans and staff

Feature “monthly_export_limit”. Default 3. List: 1 Staff gives 1000, 2 Premium gives 100, 3 Standard gives 30.

UserSegments they belong toWinnerValue
Free userNoneDefault3
Standard customerStandardRank 330
Premium customerPremiumRank 2100
Staff member on a free planStaffRank 11000
Staff member on premiumStaff, PremiumRank 11000

Notice that the staff member on premium receives the staff value, because Staff is higher. Whether that is what the business wants is a design decision, and the order is how you express it.

Example 2: A swallowed segment

Feature “new_checkout”. Default off. List: 1 All Logged-In Users gives off, 2 Beta Testers gives on. The segment “All Logged-In Users” contains almost everybody, including every beta tester. Flagsmith always matches rank 1 first, so beta testers receive “off”. The Beta Testers entry is dead weight. Moving Beta Testers above the broad segment fixes it.

Example 3: Safety first

Feature “payment_screen_v2”. Default on. List: 1 Old Browser Bug gives off, 2 Premium gives on. A bug in one browser breaks the new screen. The safety entry is first, so even premium customers on that browser see the old screen, which is what you want during an incident.

Example 4: Regions and plans together

Feature “delivery_fee”. Default 5. List: 1 Premium gives 0, 2 India gives 2, 3 Canada gives 4. A premium user in India receives 0. A standard user in India receives 2. A standard user in Canada receives 4. Think about whether a premium user should really beat a regional promotion, and choose the order accordingly.

Example 5: Percentages

Feature “smart_search”. Default off. List: 1 Staff gives on, 2 Ring 10 percent of users gives on. Staff always get it. Ten percent of everyone else get it too. Everyone else stays off. If the percentage segment were first, staff outside the ten percent would only get the feature through rank 2, which would still work here, but the order would matter if Staff had a different value.

Example 6: Equal-looking, unequal results

List orderPremium user in India getsReason
1 Premium (0), 2 India (2)0Premium is first
1 India (2), 2 Premium (0)2India is first

The two lists contain exactly the same entries. Only the order differs. That one swap changes the answer for every user who qualifies for both.

i
A habit worth keeping

For every list you build, say aloud one sentence per overlap: “When a user is both X and Y, they should get Z.” Then check that the order produces Z.

8Understanding How Groups Overlap

Ordering is only hard when groups overlap. Seeing the shapes of overlap makes the right order obvious.

Three shapes of overlap

Shape 1

Separate groups

No user can be in both, such as Free and Premium plans. Order between them does not matter. You can place them in any order, but a tidy order still helps readers.

Shape 2

Group inside a group

Every member of the small group is also in the big one, such as Premium Users in India inside Users in India. The small group should usually sit above the big one.

Shape 3

Partly overlapping groups

Some users are in both, such as Premium Users and Users in India. The order decides what the shared users get, so it must be chosen on purpose.

Analogy

Think of overlapping circles on a school notice board. Circle one is “students who play football”, circle two is “students who play chess”. Some students sit in the shared middle. If a prize is given to one circle first, the students in the middle must get it from whichever circle is read first.

Which shape do you have?

Pair of segmentsShapeDoes order matter?Sensible approach
Free Users and Premium UsersSeparateNoAny order, keep tidy
Premium in India and Users in IndiaInsideYesNarrow group first
Premium Users and Users in IndiaPartial overlapYesDecide the business rule, then order
Staff and everyone elseInsideYesStaff first
Old App Version and Premium UsersPartial overlapYesSafety rule first, then business rule

Finding hidden overlaps

Overlaps are sometimes invisible from names alone. Two segments called “Heavy Users” and “Frequent Buyers” may look different but contain nearly the same people. Check overlaps by looking at real identities, and by using the identity view in the dashboard to see which segments a sample of users belong to. Before you finalise the order, test at least one user from every overlap.

The overlap count grows fast

With two segments, there is one possible overlap. With four, there are six pairs. With ten, forty-five pairs. This is why long lists become hard to reason about, and why a small, clear set of segments, ordered by a simple principle, scales better than a long list with special cases.

2
segments make 1 pair to think about
4
segments make 6 pairs
10
segments make 45 pairs

9Principles for Choosing an Order

There is no single correct order, but there are sound principles that most teams end up following.

Principle 1: Safety rules go on top

Entries whose job is to protect customers, such as turning a feature off for a buggy browser or an unsupported app version, should be at the very top. They must win even over friendly business rules. If a bug breaks checkout on one browser, nobody wants a premium discount rule to switch the broken screen back on.

Principle 2: Exceptions above rules

Narrow, deliberate exceptions belong above broad, general rules. A pilot customer’s special limit should sit above the general plan limits. Staff access should sit above customer plans. This mirrors how rules work in law and in many systems: the most specific instruction applies first.

Principle 3: Specific above general

If one group is a subset of another, the subset goes first. “Premium in India” before “India”. “Staff in Production” before “Staff”. If the broad group were first, the narrow one could never apply.

Principle 4: Business rules by importance

Among the remaining entries, place the one the business cares most about higher. Decide in advance, with the product owner, which of two overlapping groups should win. Write the decision down.

Principle 5: Rollouts below entitlements

Temporary rollout segments, such as percentage rings, usually sit below plan and safety rules, unless the rollout is meant to override them. Keep temporary things easy to spot and easy to remove.

Principle 6: Keep a pattern

Use the same pattern for every feature you can, so that people learn it once. A common pattern is: safety, personal pilots, staff, paid plans, regions, rollouts.

1

Safety and incident switches

Always on top. Examples: broken browser, unsupported version, emergency kill group.

2

Deliberate exceptions

Pilot customers, contractual promises, named partner groups.

3

Staff and testers

Internal groups that should always see the newest behaviour.

4

Plans and entitlements

Premium, standard and similar groups, with the biggest benefit first.

5

Regions and languages

Country or locale groups.

6

Rollout rings and experiments

Temporary percentage groups that are removed when finished.

Analogy

An airline boards passengers in a set order: people needing help, then families with small children, then top members, then the rows from the back to the front. The airline never asks “who deserves it most today?” because the order is written down. A ranked list of segments plays the same role.

!
There is no free lunch

Any order favours some overlap cases over others. The goal is not a perfect order. The goal is an order that matches a business decision you can explain in one sentence.

10Step by Step: Reordering Segment Overrides

Here is the usual path in the dashboard. Labels and controls may vary a little between versions.

Before you begin

  • Open the feature in the right environment. Read the environment name twice.
  • Write down the current order, for example in a note or a screenshot, so you can undo.
  • Decide the new order and the business rule it expresses.
  • List the test users you will use afterwards: one for each overlap.
  • If the environment needs approvals, prepare the change request and the reason.

The steps

1

Open the feature

In the project, open the feature and select the environment you want to change.

2

Find the segment overrides section

You will see the list of segments that have special settings, in their current order, with the highest rank at the top.

3

Drag entries into the new order

In many versions the list can be reordered by dragging entries with a handle. Check how your version works.

4

Review the list again

Read it from top to bottom. For each pair that overlaps, check that the upper one should win.

5

Save or create a change request

Save the change. If the environment requires review, create a change request instead and ask a colleague to check it.

6

Test with real examples

Open test identities, or use fake users, and confirm that each one gets the value you expect.

7

Note the change

Write one line in your change log: which feature, which environment, what moved, and why.

Automation

Flagsmith exposes an API that includes ways to read and update the order of segment overrides. Teams use this in scripts that apply a standard order across many features. If you do this, keep the script in your code repository so that the order is reviewed like code, and always test on Staging first.

i
Small moves are safer

Move one entry at a time and check the result. A big reshuffle makes it hard to know which move caused a surprise.

11Adding a New Override: Where Does It Land?

The moment of greatest risk is not reordering. It is quietly adding a new entry and forgetting to place it.

New entries and the list

When you attach a segment to a feature for the first time, the new override appears somewhere in the list. Depending on your version, it may land at the top, at the bottom, or in some default position. Do not guess. Add a test entry in Staging and see where it lands, then write that down for your team.

Why this matters

  • A new entry landing at the top may suddenly outrank safety rules.
  • A new entry landing at the bottom may be swallowed by broader segments above it, and appear not to work.
  • Either way, the user’s experience changes the moment the entry is saved.

The two-step habit

Step 1

Add the entry

Choose the segment, set the state and value. Do not save yet if you can avoid it.

Step 2

Place the entry

Drag it to the position that matches your plan, and check overlaps.

Step 3

Save

Save once the position is right. Avoid saving first and fixing later.

Step 4

Test

Check a user inside the new segment and a user who is in both the new and an old segment.

Analogy

When a new student joins a school queue, the teacher decides where they stand. Letting them stand wherever they happen to arrive can push the whole line out of order.

Removing an entry

Removing an entry changes the winner for everyone who relied on it. Users who matched that entry now fall to the next matching one below, or to the default. Before you delete, think about who they will land on, and test those users.

Disabling instead of deleting

Some versions let you switch an override off without deleting it, which keeps its place in the list. If available, this is a gentle way to test the effect of removal. Check your version before relying on it.

!
Common slip

A person adds a beta-tester segment during a launch, and the new entry lands above the safety segment. Nothing seems wrong until a bug appears on the affected browser and beta testers are the only ones still seeing the broken page.

12Priority With Multivariate Values and Percentage Splits

Flags are not always a simple yes or no. Priority interacts with several-valued flags and random-looking splits in specific ways.

Multivariate flags

A multivariate flag has several possible values, split by percentages. A button might be blue for half of users, green for thirty percent and orange for twenty percent. A segment override can change this: for one group, the split can be different, or fixed to one value.

Priority works the same way. The first matching segment entry decides the state and the split used for that user. The user is then given one of the values according to that entry’s percentages. Entries below are not consulted.

An example

Button colour test

Feature “buy_button_colour”. Default: 50 percent blue, 30 percent green, 20 percent orange. List: 1 Staff, always blue. 2 New Customers, an even split between blue and green. A new customer who is also staff matches Staff first and always sees blue. A new customer who is not staff matches New Customers and sees blue or green. Everyone else follows the default split.

Percentage-split segments

A percentage-split rule picks a stable share of users using their identifier. It can be used inside a segment, for example “ten percent of users”, and that segment can then be attached to a feature like any other. Because the share is stable, the same user is always inside or always outside for a given percentage.

Where to place percentage segments

  • Below entitlements. If a paid plan has a guaranteed feature, it should not depend on a lucky ten percent.
  • Below safety rules. A safety switch must apply to everyone it needs to, not only to those outside the ring.
  • Above the default. The ring is meant to pull people away from the default, so it must be checked before the default is used.
  • Ordered by size when stacked. If several rings exist, such as ten and fifty percent, put the smaller, more specific ring first, so its users get the early value. Then the larger ring, then the default.
flowchart TD
    U["User requests feature"] --> S1{"In safety segment?"}
    S1 -- "Yes" --> R1["Safety value"]
    S1 -- "No" --> S2{"In paid plan segment?"}
    S2 -- "Yes" --> R2["Plan value"]
    S2 -- "No" --> S3{"In 10 percent ring?"}
    S3 -- "Yes" --> R3["Ring value"]
    S3 -- "No" --> S4{"In 50 percent ring?"}
    S4 -- "Yes" --> R4["Wider ring value"]
    S4 -- "No" --> R5["Default"]
Figure 5: A sensible order mixing safety, plans and rollout rings

A subtle trap with nested rings

Rings are usually nested: everyone in the ten percent ring is also in the fifty percent ring. If you place the fifty percent ring above the ten percent ring, and they give different values, the ten percent entry will never be used, because fifty percent matches first. Always put the narrower ring first.

i
Tip

When you widen a ring from ten to fifty percent, you can simply raise the percentage in the same entry. You do not need a second entry unless the two rings must give different values.

13Priority Versus Rule Logic Inside a Segment

Two kinds of ordering-like ideas live in Flagsmith. Keeping them separate saves hours of confusion.

Inside a segment: ALL, ANY and NONE

A segment is made of rules, and each rule contains conditions. Conditions combine as ALL (every one must match, like “and”), ANY (at least one must match, like “or”) or NONE (none may match, like “not”). These control membership. They do not carry a rank, and the order in which you list conditions inside a rule makes no difference to who is a member.

Across segments: priority

Priority is only about which segment’s override wins when several segments say yes. It does not change who is a member of any segment.

IdeaWhere it livesWhat it decidesDoes order matter?
ALL, ANY, NONEInside a segment ruleWho is a memberNo, the order of conditions does not matter
Segment priorityOn a feature in an environmentWhose setting winsYes, strongly
Identity overrideOn a feature in an environmentPersonal exceptionAlways before segments

Do not simulate priority with rules

Some teams try to build order into segment rules, for example by writing “plan is premium AND NOT staff” so that staff and premium never overlap. This can work, but it hides the order inside the rules, spreads the logic across many segments and makes later changes harder. In most cases, it is clearer to keep segment definitions simple and describe their precedence through the ordered list.

Using order to express precedence

  • Segment definitions stay simple and reusable.
  • The decision “who wins” is visible in one list.
  • Changing precedence means moving one entry.

Using rules to express precedence

  • Segments become tangled with “not this, not that” conditions.
  • One change in a rule may break several features.
  • The real order is hard to see.
Analogy

A guest list for a party says who is invited. A seating plan says where each guest sits. Mixing the two, for example by inviting only guests who happen to fit at a particular table, makes both harder to manage.

A short rule of thumb

Use rules to describe who belongs. Use order to describe who wins. If you find yourself adding “and not in group X” to many rules, consider whether a plain ordered list would be clearer.

14Priority Is Applied to Live Traits

Segment membership is not fixed. It follows the user’s facts. That makes priority dynamic, and a little surprising.

Traits change, winners change

Flagsmith evaluates segment membership every time flags are requested, using the user’s latest traits. If a customer upgrades from standard to premium, the trait “plan” changes. On the very next request, the user matches Premium, not Standard, and the winner changes. Nobody moves the user between groups by hand.

sequenceDiagram
    participant B as Billing System
    participant F as Flagsmith
    participant U as User App
    B->>F: Set trait plan to premium
    U->>F: Request flags for user
    F->>F: Evaluate segments in priority order
    F-->>U: Value from the Premium entry
Figure 6: A trait change alters the winner on the next request

Temporary double membership

During a change, a user may briefly belong to two segments. For example, a user who just became premium may still carry an old “trial” trait. Priority decides the result, and a poorly chosen order can give the user the wrong value until the old trait is cleared. Good housekeeping of traits and sensible ordering work together.

Segments that flip often

Some traits change quickly, such as “orders this month” or “minutes active today”. Users may move in and out of segments during a day. If priority makes those segments produce very different values, the experience can flicker. Avoid using fast-changing facts for high-impact settings, or add a small buffer, such as a “weekly” trait that updates once a day.

Anonymous and missing traits

A user with no value for a trait does not match rules about that trait, unless the rule is about the trait being absent. If a high-ranked entry depends on a trait that is sometimes missing, those users fall through to lower entries. Test the missing case for each trait that appears in a high-ranked segment.

!
Watch the data

An unexpected winner is often a data problem, not an ordering problem. A stale trait puts the user in the wrong segment, and priority then faithfully applies the wrong entry.

A debugging question to ask

When a user gets an unexpected value, ask two questions in this order: “Which segments is this user in right now?” and then “In what order are those segments in the feature’s list?” The first question is about data. The second is about priority. Do not skip the first.

15Priority Across Environments, Promotion and Cloning

Orders do not travel automatically. Knowing when they do and do not move prevents classic launch-day surprises.

Each environment has its own order

The ranked list for a feature in Staging is a separate list from the one in Production. Changing the order in Staging does nothing to Production. It is easy to test an order in Staging, be happy, and forget that Production still has the old one.

Promotion is a repeat, not a copy

Moving a change from Staging to Production usually means repeating the same change in Production, by hand or by script. The order must be set again, on purpose. Treat the order as part of the change, and include it in the plan: “Add Beta Testers entry, place it below Staff and above Premium.”

Cloning an environment

Flagsmith can create a new environment by cloning an existing one. A clone generally copies feature states, values and segment overrides. Whether it preserves the order of overrides exactly is something to check in your own version, by opening a few features in the clone and comparing the lists to the source. Do not assume. If the clone will be used to rehearse a launch, confirm the order before you trust it.

SituationDoes order move by itself?What to do
Change order in StagingNo, Production is unaffectedRepeat the change in Production deliberately
Create a new feature override in ProductionNo, other features are unaffectedPlace the entry for each feature
Clone an environmentCheck in your versionCompare lists in the clone against the source
Rename a segmentOrder stays, name changesUpdate your documentation
Delete a segmentIts entries disappear from listsCheck who falls to the next entry
Analogy

A restaurant with two branches keeps a separate queue at each door. If the manager changes who goes first at one door, the other door’s queue stays as it was, unless the manager walks over and changes it too.

Drift between environments

Over time, small differences creep in. Production gains a hotfix entry that Staging lacks. Staging gets a test segment that Production never needs. Once a quarter, compare the lists of your most important features in all environments and write down why each difference exists.

i
Tip

Keep a “reference order” document per feature family, and treat it as the plan. Staging and Production should both follow it, with differences noted.

16Remote and Local Evaluation Follow the Same Order

Flagsmith can decide the answer in two places. The priority rules are the same in both.

Remote evaluation

In remote evaluation, the app asks Flagsmith for flags and Flagsmith works out the answer on its servers, using stored traits and any sent with the request. Segment priority is applied by Flagsmith.

Local evaluation

In local evaluation, a trusted server program downloads the whole environment configuration, including features, segments, overrides and their order, and works out answers by itself using the traits you supply. The same priority order is applied, using the same rules, by code inside the SDK.

What can differ

TopicRemote evaluationLocal evaluation
Order of overridesApplied on Flagsmith serversApplied inside your server using a downloaded copy
Freshness of order changesAlmost immediateAfter the next refresh of the downloaded copy
Traits usedStored plus sentUsually only those you supply at call time
Typical delay after reorderingSecondsUp to the refresh interval
Analogy

Remote evaluation is phoning head office, which always uses the latest rulebook. Local evaluation is checking a printed copy of the rulebook on your desk. The rules are the same, but your copy might be a few minutes old after a change.

Planning around the delay

  • After reordering, expect servers using local evaluation to catch up only after their refresh.
  • For urgent safety changes, check that your servers refresh quickly enough, or use a short refresh interval for those services.
  • Do not test a new order from a service that uses an old copy, or you will think the change failed.

Different SDKs, same promise

Flagsmith aims for every SDK to give the same answer for the same data. If you ever see a different result between two SDKs for the same user, check the trait values being supplied, and check SDK versions. Differences are usually in the input, not in the ordering logic.

!
Keep SDKs current

New operators and behaviours arrive in newer SDK versions. If an old SDK does not understand a newer rule type, it may treat it differently. Keep SDKs updated, and test after upgrades.

17Priority, Change Requests, Versioning and Scheduling

Reordering is a real change with real effects. Flagsmith offers controls that help you handle it with care.

Reordering as a guarded change

Some plans of Flagsmith offer an approval workflow, sometimes called change requests, where a second person must approve a change to a protected environment before it goes live. Changes to segment overrides, and potentially their order, may be covered. Which actions are guarded can differ by version, so test it once in Staging and write down the result. If reordering is guarded, use the workflow for production lists that affect many users.

What a reviewer should check

Check

The before and after

Is the new order what the plan says? Compare the two lists, entry by entry.

Check

Each overlap

For each pair of overlapping segments, does the upper one deserve to win?

Check

Safety on top

Are all safety entries still above business entries?

Check

Test results

Has the author tested at least one user from every overlap?

Versioning

Some versions of Flagsmith keep numbered versions of a feature’s settings in an environment, so that you can see earlier states and prepare a future state. If your version has this, the order of segment overrides may be part of each version. Check whether you can see how the order looked a week ago. This is very helpful when someone asks, “What was the order last Tuesday, when this complaint happened?”

Scheduling

Where scheduling is available, a planned change can take effect at a chosen time. If a launch needs a new order to apply at the same moment as a new entry, plan both changes together, so that the list is never in an in-between state that nobody reviewed.

The audit log

Flagsmith’s audit log records who changed what and when. Reordering should appear there. If a group of users suddenly receive different values, look at the audit log for the feature in that environment, and see whether anyone changed an entry or moved one a few minutes earlier.

i
Habit

Write the old order into the change request or the change log. If something goes wrong, the old order is the quickest route back.

18Architecture and Core Components

To trust a system, it helps to know what it is made of. Here are the parts behind segment ordering.

The building blocks

Data

Segment

The named group with its rules. Lives at project level.

Data

Feature

The named switch. Lives at project level.

Data

Segment override record

The link between one segment and one feature in one environment, with a state, a value and a rank.

Data

Identity and traits

The facts about a user that segments read.

Engine

Evaluation engine

The code that checks membership and walks the ranked list.

Delivery

API, cache and SDKs

The path that carries answers to apps, quickly and at scale.

flowchart LR
    TEAM["Team in Dashboard"] --> API["Flagsmith API"]
    API --> DB[("Database")]
    DB --> OV["Segment override records with rank"]
    DB --> SEG["Segments and rules"]
    DB --> ID["Identities and traits"]
    APP["App with SDK"] --> API
    API --> ENG["Evaluation Engine"]
    ENG --> OV
    ENG --> SEG
    ENG --> ID
    ENG --> CACHE["Read Cache or Edge Layer"]
    CACHE --> APP
Figure 7: Where segment overrides and their ranks sit in the system

The rank is just a number

Inside the database, each segment override record carries a rank, essentially a number that says where it sits in its feature’s list. The dashboard shows this as an ordered list. When you drag an entry, the numbers are updated so that the list reads in the new order. The engine sorts by these numbers and walks the list.

Two kinds of traffic

Flagsmith handles flag reading, which is constant and heavy, and management actions such as reordering, which are occasional. The two paths are kept apart, so a busy dashboard does not slow down apps. A reordering is saved on the management side, then copied to the fast read layers, after which apps see the new order.

Analogy

The ranked list is a numbered list on the clipboard of a bouncer. Renumbering the list is done in the office. The bouncers at the doors receive a fresh copy afterwards. Visitors never wait for the office work.

19How a Reorder Works Internally

Let us follow a single drag-and-drop from the dashboard until the apps see the new order.

Step by step

1

You move an entry

In the dashboard you drag “Premium” above “India” in the list for one feature in one environment.

2

The dashboard sends the new order

It tells the Flagsmith API the full new sequence of entries for that feature and environment.

3

Permissions are checked

Flagsmith confirms that you may change this environment. If approvals are required, the change may become a request instead.

4

Ranks are rewritten

The rank numbers of the entries are updated together, so that the list reads in the new order.

5

The audit entry is written

The change is recorded with your name and the time.

6

Read layers are refreshed

Caches and edge copies receive the new data, so apps asking for flags are answered with the new order.

7

Apps pick up the change

Remote apps see it at their next request. Servers with local evaluation see it after their next refresh.

sequenceDiagram
    participant T as Team Member
    participant D as Dashboard
    participant A as Flagsmith API
    participant S as Database
    participant C as Read Cache
    participant P as Apps and SDKs
    T->>D: Drag Premium above India
    D->>A: Save new order for feature and environment
    A->>S: Update ranks together
    A->>S: Write audit entry
    A->>C: Refresh cached data
    P->>C: Request flags
    C-->>P: Answers using the new order
Figure 8: From a drag in the dashboard to new answers in apps

All-or-nothing updates

The rank updates are saved as a group, called a transaction. A transaction either completes fully or not at all. Think of paying in a shop: either the money leaves your account and you get the goods, or neither happens. For ordering, this means the list is never left half-reordered, with two entries sharing a rank or an entry missing.

Why the read path stays fast

Apps do not wait for the reorder. They keep reading from fast layers, and receive the updated data when it arrives. The management write takes a moment, the read refresh takes another moment, and in total most changes appear within seconds.

i
Planning

Do not promise to the second that a reorder will reach every user. Plan for a short settling time, and watch dashboards a few minutes after any important change.

20The Life of a Priority List

A ranked list is not a one-time creation. It grows, drifts and eventually needs cleaning. Planning for its life prevents decay.

Stage 1: Birth

The first segment override is added to a feature. The list has one entry, and order is meaningless. This is the cheapest moment to decide on a pattern.

Stage 2: Growth

More entries arrive: staff, plans, regions, a pilot customer. Each new entry must be placed. Without a pattern, the list grows in the order things were added, which is rarely the order things matter.

Stage 3: Complexity

Overlaps multiply. Exceptions are added above rules. Someone adds an entry to fix an urgent problem and puts it on top. The list becomes hard to read from top to bottom.

Stage 4: Drift

The list no longer matches the original plan. Entries remain whose purpose nobody remembers. Staging and Production differ. Documentation is out of date.

Stage 5: Cleaning

A team reviews the list, deletes dead entries, moves entries back to the pattern and rewrites the plan. The list becomes short and readable again.

stateDiagram-v2
    [*] --> Born: First override added
    Born --> Growing: More segments attached
    Growing --> Complex: Overlaps and exceptions pile up
    Complex --> Drifting: Plan and reality diverge
    Drifting --> Cleaned: Review, delete, reorder
    Cleaned --> Growing
    Growing --> Retired: Feature fully launched and flag removed
    Cleaned --> Retired
    Retired --> [*]
Figure 9: The life of a ranked list of overrides

What to do at each stage

StageHealthy habit
BirthChoose the pattern and write it down
GrowthPlace every new entry on purpose, with a test
ComplexityAdd notes for exceptions, and set an end date for temporary ones
DriftCompare against the plan once a quarter
CleaningDelete unused entries and re-test overlaps
RetirementRemove the flag and its overrides when the feature is finished

Temporary entries need exits

Rollout rings, incident switches and pilot groups are meant to be temporary. If nobody removes them, they remain in the list long after their purpose is gone, still holding positions of power. Attach an end date or a ticket to every temporary entry, so that someone is responsible for removing it.

Analogy

A noticeboard fills with notes over time. Old notices hide new ones, and nobody can tell which are still true. A caretaker who clears expired notices each month keeps the board useful.

21Performance, Scalability and High Availability

Products with millions of users need targeting that stays fast. Here is how list length and order interact with performance.

The cost of walking a list

For each flag request, Flagsmith must walk the ranked list for each feature until it finds a match. A short list costs almost nothing. A long list, with many entries and complicated rules, costs more, because each test of membership means comparing traits against rules. Because the walk stops at the first match, placing entries that match many users near the top can also save work.

Millions
flag reads per minute in big products
Few
entries per feature in a healthy list
Seconds
for a reorder to reach apps

Ways to keep it light

Length

Keep lists short

Delete entries that no longer matter. A list of five is easier than a list of fifty.

Rules

Keep rules simple

Prefer plain equals or list matches over heavy text patterns.

Sharing

Reuse segments

One clear “Premium Users” segment across features beats several near-copies.

Delivery

Use caches and edge layers

Let fast read layers answer popular requests close to users.

Delivery

Use local evaluation for heavy servers

Decide on your own server, and save round trips.

Hygiene

Retire finished flags

Old flags with long lists slow every response.

Availability

If Flagsmith has a bad day, apps should keep working. Give every flag a safe default value in the code, so features fall back to sensible behaviour. Let SDKs keep a recent copy of flags where possible. Managed Flagsmith spreads reads across fast layers. A self-hosted installation can run several copies of the API behind a load balancer, with a standby database.

Scaling the human side

The more entries a list has, the more people it takes to understand it. Splitting products into separate projects, keeping a clear pattern and documenting precedence scale the human side far better than any software setting.

!
Do not rely on instant changes

Caches and refresh timers mean that a reorder takes a few moments to reach everyone. Avoid designs that need all users to switch at exactly the same instant.

22Security, Permissions and Compliance

Whoever controls the order controls what users receive. That deserves care.

Order is power

Moving one entry can switch a safety rule behind a convenience rule, or hand a premium feature to a group that should not have it. Because the power is so concentrated in one list, limit who can edit it in production.

A sensible permission model

RoleDevelopmentStagingProduction
All engineersEdit freelyEdit freelyView, propose
Feature ownersEdit freelyEdit freelyEdit own features with review
On-call engineersEdit freelyEdit freelyEdit, including emergency
Product managersViewView, proposeView, propose
SupportViewViewView identities when needed
AdministratorsSettings onlySettings onlySettings only

Separation of duties

Many standards want one person to propose an important change and another to approve it. Use the approval workflow, where your plan offers it, for production lists. The record shows who proposed and who approved each reorder.

Audit and traceability

The audit log answers: who changed the order, when, and in which environment. For regulated businesses, this is part of the evidence that changes are controlled. Combine the audit log with a written plan, so reviewers can see both what changed and why.

Least privilege

The principle of least privilege says people should have only the access their work needs. In this context: engineers who only occasionally change production lists should propose and let others approve, instead of holding permanent edit rights.

Protect the keys

Servers that use local evaluation download the entire set of rules and orders using a server-side key. That key can read your targeting rules. Store it in a secrets manager, keep it out of client apps, and rotate it from time to time.

!
Hidden risk

A reorder can quietly change who receives a paid feature. Treat order changes in production with the same seriousness as a code change to billing logic.

23Debugging: Why Did This User Get That Value?

The most common support question about priority is “why did this user get that value?” A calm routine answers it quickly.

The routine

1

Confirm the environment and the user

Is the app using the environment key you expect? Is the identifier the one you are searching for?

2

Look for an identity override

A personal setting beats everything. Check the identity page first.

3

List the traits

Check each trait’s spelling, type and value. Missing traits explain many surprises.

4

List the segments the user is in

The identity page in the dashboard can usually show the segments an identity currently belongs to.

5

Read the feature’s ranked list

Starting at the top, find the first segment from step 4. That entry is the winner.

6

Compare with what the app shows

If the winner’s value differs from what the user sees, suspect caching, an old SDK copy or a local evaluation refresh.

7

Check the audit log

See whether the list or a segment was edited recently.

Read the list aloud

A surprisingly effective technique is to read the list aloud like a bouncer: “Is this person Staff? No. Premium? Yes. Then Premium wins.” Saying it slowly often reveals an entry that does not belong.

Common explanations in order of frequency

CauseHow oftenHow to confirm
Data issue: wrong, missing or stale traitVery commonOpen the identity and check traits
A higher entry swallows the expected oneCommonRead the list from the top
Identity overrideCommonCheck the identity page
Wrong environmentCommonCheck the key in the app
Cache or refresh delayOccasionalWait, restart, check refresh interval
Segment edited recentlyOccasionalCheck the audit log
i
Write the answer down

When you solve a puzzle, add one line to a shared troubleshooting page. Most puzzles repeat.

24Testing Priority Before Customers See It

A ranked list is a small program. Like any program, it needs tests, especially where groups overlap.

Build an overlap test matrix

For each feature, list the segments in order. Then list imaginary users who belong to each combination that matters. For every one, write down the expected value, and check it against Flagsmith using fake identities in a safe environment.

Test userTraitsSegmentsExpected winner
Plain free userplan free, country BRNoneDefault
Premium onlyplan premium, country BRPremiumPremium entry
India onlyplan free, country INIndiaIndia entry
Premium in Indiaplan premium, country INPremium, IndiaWhichever the plan says is higher
Staff on premiumis_staff true, plan premiumStaff, PremiumStaff entry
Old app on premiumapp 4.9.9, plan premiumOld App, PremiumSafety entry
Missing plancountry IN onlyIndiaIndia entry

Test in Staging that looks like Production

Use a staging environment with the same segments and the same order as Production. Name test users so they cannot be mistaken for real ones, such as “test-premium-india-01”. Never test by editing real customers’ traits.

Test after every change

  • After adding an entry: test one user inside the new segment and one who is also inside an older, higher segment.
  • After reordering: test every overlap that involves the moved entry.
  • After deleting an entry: test users who used to match it, and see where they land.
  • After changing a segment’s rule: test users near the edge of the rule.

Keep the test table

Store the matrix with the feature’s documentation. When the list changes, update the table. A table that is reused gets better over time and catches mistakes in future changes.

Analogy

A theatre runs a dress rehearsal before opening night. Actors wear their costumes, but the audience is a few friends. Testing with fake users is the dress rehearsal for your ordering.

!
Edges hide bugs

Most priority bugs hide at overlaps: the premium user in India, the staff member on a free plan, the beta tester on an old app. Test those on purpose.

25Failure Scenarios and Recovery

Mistakes will happen. Good teams know the usual ones and have a calm response ready.

Scenario 1: A new entry swallowed an old one

A broad segment was added at the top. A narrow segment below it stopped working, and nobody noticed until a pilot customer complained. Response: move the narrow entry above the broad one, test the overlap, and add the case to your test table.

Scenario 2: A safety entry was pushed down

During a launch, a new rollout entry landed above the safety entry. A bug on one browser reappeared for users in the rollout. Response: move the safety entry back to the top at once, then review the pattern and who may edit the list.

Scenario 3: A reorder was applied in the wrong environment

Someone meant to change Staging and changed Production. Response: restore the old order, which you wrote down beforehand, check a few users and write a short incident note. Reduce the chance of a repeat by using clear environment names and approval workflows for production.

Scenario 4: A segment was deleted

Entries that depended on it disappear from lists, and users fall to the next match or the default. Response: recreate the segment with the same rule, reattach it in the correct positions and test. This is why deletion should be rare and planned.

Scenario 5: Staging and Production disagree

A launch works in Staging and fails in Production because the order differs. Response: compare the lists, align them with the plan and note which differences are intended.

Scenario 6: Local evaluation shows an old order

A server keeps behaving the old way after a reorder. Response: check its refresh interval, force a refresh if possible and look for an old SDK version.

flowchart TD
    S["Unexpected value for some users"] --> Q1{"Did the list change recently?"}
    Q1 -- "Yes" --> A1["Compare with the old order and restore if needed"]
    Q1 -- "No" --> Q2{"Is the user's data right?"}
    Q2 -- "No" --> A2["Fix traits and sync sources"]
    Q2 -- "Yes" --> Q3{"Is the app using the right environment and a fresh copy?"}
    Q3 -- "No" --> A3["Correct the key or refresh the app"]
    Q3 -- "Yes" --> A4["Read the ranked list from the top and look for swallowing"]
Figure 10: A calm path for sorting out surprising values

Habits that make recovery easy

  • Write down the old order before every change.
  • Keep a short, tested reference order for each feature family.
  • Use approvals for production lists that affect many users.
  • Have a one-minute undo plan for every launch.
  • Practise: once a quarter, rehearse restoring a list in Staging.

26Advantages, Disadvantages and Trade-offs

Ranked lists are simple and powerful. They also have costs. Here is an honest look.

Advantages

  • Easy to explain: read from the top, stop at the first match.
  • Deterministic: the same inputs always give the same answer.
  • Changes need no new release.
  • Precedence is visible in one place.
  • Works the same in remote and local evaluation.
  • Lets specific cases beat general ones.

Disadvantages

  • Overlaps can be hard to see from names.
  • One misplaced entry can silently change results.
  • Lists drift over time without care.
  • Each feature and environment has its own list.
  • Only the first match counts, so no combining of settings.
  • Long lists are hard for people to reason about.

First match versus combining

In some systems, several matching rules can add their effects together. In Flagsmith’s ranked list, the first match wins and nothing is combined. This is simple and predictable, but it means that if you want “premium customers in India get both the premium limit and the India bonus”, you must create a segment for that exact combination and place it above both.

One list versus many segments

ApproachStrengthWeakness
Few broad segments, careful orderShort lists, easy to readCannot express every special case
Many narrow segments for every combinationExact controlLong lists, hard to maintain
Derived traits computed in the backendSimple rules, logic in code you controlNeeds work in your own systems

Flexibility versus safety

The freedom to add any entry anywhere is also the freedom to break precedence. Use permissions, approvals and written patterns to keep the freedom useful.

A good order is short enough to read in a minute and clear enough to explain in a sentence.

27Design Patterns and Anti-Patterns

Patterns are habits that other teams have already tested. Anti-patterns are habits that looked clever and then caused pain.

Pattern 1: The standard ladder

Use one standard order for all features: safety, deliberate exceptions, staff, plans from highest to lowest, regions, rollout rings. Every feature starts from this ladder, and teams delete the rungs they do not need.

Pattern 2: Combination segments above components

When a combination of groups needs a special result, create a segment for the combination and place it above the two component segments. Name it clearly, such as “Premium in India”.

Pattern 3: Derived traits

Compute a single label in your backend, such as “customer_tier”, from many raw facts. Segments then read one trait, and overlaps shrink because the tiers do not overlap.

Pattern 4: Safety shelf

Keep a small set of segments, such as “Known Bad Browser” or “Unsupported App”, whose only job is to protect users. They always sit at the top, and only a few trusted people may edit them.

Pattern 5: Temporary rungs with tickets

Every temporary entry carries a ticket number in its name or description and an expected removal date. Review them weekly during a launch.

ANTI-PATTERN 01 Avoid
What it looks like

A catch-all segment such as “All Logged-In Users” sits near the top of the list.

Why it hurts

It matches nearly everyone, so entries below it almost never apply.

Better approach

Put catch-all entries at the bottom, or use the environment default instead.

ANTI-PATTERN 02 Avoid
What it looks like

New entries are always added at the top because it feels like the most important place.

Why it hurts

Over time, the oldest rules sink to the bottom, and the list shows the order things were added, not the order that matters.

Better approach

Place every new entry according to the standard ladder.

ANTI-PATTERN 03 Avoid
What it looks like

Hidden precedence inside rules, such as “plan is premium and not staff and not India”.

Why it hurts

The real order is scattered across many segments, and changes are risky.

Better approach

Keep rules simple, and express precedence with the ordered list.

ANTI-PATTERN 04 Avoid
What it looks like

A different order for every feature, with no explanation.

Why it hurts

Nobody can remember them, and reviewers cannot spot mistakes.

Better approach

Use the standard ladder, and document every deliberate difference.

ANTI-PATTERN 05 Avoid
What it looks like

Dozens of identity overrides used instead of a clear segment.

Why it hurts

Personal exceptions beat the whole ranked list, so changes to the list no longer reach those users, and nobody remembers why each exists.

Better approach

Create a named segment for the group, with an owner and an end date.

28Best Practices, Common Mistakes and Troubleshooting

Experienced teams build a few simple habits. Beginners tend to make the same few slips.

Best practices

1

Write the ladder down

One page that says which kinds of segments go where.

2

Safety always on top

Never let a convenience rule outrank a safety rule.

3

Narrow above broad

Subsets go before the sets that contain them.

4

Place new entries on purpose

Check where a new entry lands and move it before saving.

5

Test every overlap

One test user per combination that matters.

6

Record the old order

Write it before each change, so undo takes a minute.

7

Review production lists

Use approval workflows where available.

8

Clean every quarter

Remove dead entries and compare environments.

Common mistakes

Mistake

Confusing membership and priority

Fixing a segment rule when the real problem is the order, or the other way round.

Mistake

Forgetting identity overrides

A personal setting quietly beats every segment.

Mistake

Assuming one order everywhere

Each feature and environment has its own list.

Mistake

Not testing overlaps

Tests cover the simple cases and miss the combined ones.

Mistake

Leaving temporary entries

Old rollout rings keep their power for months.

Mistake

Blaming priority for bad data

A stale trait puts the user in the wrong segment, and the order is innocent.

Troubleshooting guide

SymptomLikely causeWhat to do
A segment override never seems to applyA higher entry matches firstMove it above the broader entry and test
A user ignores all segment changesIdentity override existsCheck the identity page and remove if not needed
Works in Staging, not in ProductionDifferent order or different segmentsCompare the two lists
Change not visible yetCache or refresh delayWait a few moments and refresh
Premium users lose a benefitA lower-value entry moved aboveCheck the audit log for recent reorders
Different servers disagreeOne uses an old copy with local evaluationCheck refresh interval and SDK versions
New entry has odd effectIt landed at the top or bottom unexpectedlyCheck its position and move it

29Governance and Documentation

A good order is easy to break and easy to forget. Written habits keep it alive when people change jobs.

The priority map

A priority map is a one-page document that shows, for each important feature family, the intended order of segments and the reason for each position. It is the plan against which reality is checked. It does not need to be fancy. A table is enough.

RankSegmentPurposeOwnerTemporary?
1Known Bad BrowserSafety switch for a browser bugWeb teamUntil bug is fixed
2Pilot Customer APromised higher limitCustomer teamUntil contract ends
3StaffEarly access for employeesIT teamNo
4Premium UsersPaid plan entitlementBilling teamNo
5Standard UsersPaid plan entitlementBilling teamNo
6India UsersRegional launchRegional teamUntil launch is complete
7Ring 10 percentGradual rolloutFeature teamYes, remove after launch

Who owns the order?

Every feature has an owning team, and that team owns its list. The owner decides the order, with advice from the owners of the segments involved. A shared segment such as Staff has its own owner, who must be told when its position or definition changes.

Change notes

Whenever you change an order, write a short note: which feature, which environment, what moved, why, who is affected, how to undo. Put it in a change log or in the change request. A year later, these notes answer questions that nobody else can.

Regular reviews

  • Weekly during a launch. Check temporary entries and the status of rings.
  • Quarterly in normal times. Compare actual lists with the priority map, and clean up.
  • After incidents. If a surprise was caused by order, update the map and the tests.

Teaching newcomers

New teammates should learn four things in their first week: the three layers of authority, the standard ladder, how to debug a user’s value and where the priority map lives. A short walk-through with a real example from your own project is worth more than a long manual.

i
Make it easy

Keep the priority map where people already work, such as your team wiki, and link it from each feature’s description. A map that is hard to find is a map that nobody follows.

30Advanced Topics: Keeping Lists Short and Consistent

Once you master the basics, the real art is keeping lists short, consistent and easy to change.

Combination segments and the explosion problem

Because the first match wins and nothing is combined, special results for combinations need their own segments. With three plans and three regions, covering every pairing could mean nine combination segments. With more dimensions, it explodes. If you find yourself creating combination segments again and again, step back.

Solution 1: Derived traits

Compute in your own backend a single trait, such as “offer_tier”, that already includes the logic you want: “gold_india”, “gold_other”, “basic”. Flagsmith then needs one segment per tier, and there are no overlaps. The complexity moves into code you control, where it can be tested with ordinary tools.

Solution 2: Separate features for separate decisions

If one feature must answer too many questions, split it. Instead of a single “delivery_fee” with a long list, create “delivery_fee_by_plan” and “delivery_fee_regional_discount”, each with a short list, and let the app combine the two answers. Each list stays simple, and the combination is explicit in code.

Solution 3: Use values, not segments

Sometimes the app can receive a value and do the combining itself. A feature that returns a base number and another that returns a bonus number can be added in code. This keeps Flagsmith simple and puts arithmetic where it belongs.

ApproachBest whenCost
Combination segmentsOnly a few special combinations existLists grow if combinations multiply
Derived traitsMany dimensions combineBackend work, trait to maintain
Split featuresOne feature answers unrelated questionsApp must combine the answers
Values combined in codeRules are arithmetic, not choicesLogic lives partly in app code

Consistency across features

If twenty features use the same five segments, strive for the same relative order in every list. When a rule must be different, note why. Consistency lets reviewers spot mistakes by pattern: “This list has Premium above Staff, which is different from all the others. Is that on purpose?”

flowchart TD
    A["Many overlapping segments in lists"] --> B{"Are the same combinations repeated across features?"}
    B -- "Yes" --> C["Create a derived trait in the backend"]
    B -- "No" --> D{"Does one feature answer unrelated questions?"}
    D -- "Yes" --> E["Split it into separate features"]
    D -- "No" --> F["Keep the list and use the standard ladder"]
    C --> G["Shorter lists, fewer overlaps"]
    E --> G
    F --> G
Figure 11: Choosing a way to keep ranked lists short

Replacing a segment safely

When a segment must change in a major way, create the new version beside the old one, attach it to features just below the old one, compare results with test users, switch the order, and then delete the old one. This avoids a sudden change in who matches many features at once.

Measuring list health

  • Average and longest list length per feature.
  • Number of entries not matched by any user in the last month.
  • Number of temporary entries past their end date.
  • Number of differences between Staging and Production lists.
  • Number of identity overrides per feature.
i
A test of design

If you can explain every list to a colleague in one minute, your ordering is healthy. If you need a diagram and ten minutes, simplify.

31A Complete Walkthrough: A Delivery Fee for Acme Cart

Let us follow a made-up online shop, “Acme Cart”, through a full piece of work to see how the ideas fit together.

The situation

Acme Cart has two million monthly shoppers, three plans (free, standard, premium), staff accounts and operations in several countries. The team wants a feature called “delivery_fee” with the following business rules, agreed with the product owner: premium customers always pay nothing; staff always pay nothing; customers in a launch region get a reduced fee during the launch; everyone else pays the standard fee. An old app version cannot show fees correctly and must see a flat fee.

Stage 1: Write the rules as sentences

The team writes each overlap as a sentence. “When a user is premium and in the launch region, they pay nothing.” “When a user is on the old app and premium, they still see a flat fee, because the old app cannot show nothing correctly.” The second sentence reveals that the old-app rule is a safety rule and must be on top.

Stage 2: Choose the order

RankSegmentFeeReason
1Old App VersionsFlat 5Safety: the old app cannot display other values
2Staff0Always free for staff
3Premium Users0Paid plan benefit
4Launch Region2Temporary promotion
DefaultEveryone else5Standard fee
flowchart TD
    U["User asks for delivery_fee"] --> I{"Identity override?"}
    I -- "Yes" --> V0["Personal value"]
    I -- "No" --> A{"Old App Versions?"}
    A -- "Yes" --> V1["Flat 5"]
    A -- "No" --> S{"Staff?"}
    S -- "Yes" --> V2["0"]
    S -- "No" --> P{"Premium Users?"}
    P -- "Yes" --> V3["0"]
    P -- "No" --> L{"Launch Region?"}
    L -- "Yes" --> V4["2"]
    L -- "No" --> V5["Default 5"]
Figure 12: The delivery_fee decision path for Acme Cart

Stage 3: Build and test in Staging

The team builds the list in Staging and creates test users: a free user in the launch region, a premium user in the launch region, a staff member on the old app, a standard customer elsewhere and a user with no plan trait. They check each result against the table. They notice that the staff member on the old app gets a flat fee, as designed, and that the user with no plan falls to the Launch Region entry if in the region. All match their expectations.

Stage 4: Review and apply in Production

An engineer proposes the same list in Production through a change request, including the order and the test table. A second engineer reviews each overlap against the written sentences and approves. The change is applied. The team checks a handful of real accounts and watches checkout graphs for an hour.

Stage 5: A surprise and a fix

Two days later, a customer success manager reports that a loyal customer, who was promised free delivery in a contract, is being charged the launch-region fee. The team finds that the customer is not premium, and so lands on Launch Region. They create a segment “Pilot Customer A” with a rule on the trait “company_id”, place it at rank 2, below the safety entry and above Staff, add a test user and update the priority map. The customer receives free delivery on the next request.

Stage 6: Clean up after the launch

When the promotion ends, the team removes the Launch Region entry, checks which users fall to the default and confirms that nothing else depended on it. They update the priority map and close the ticket.

Worked well

  • Rules were written as sentences before building.
  • The safety entry was on top from the start.
  • Test users covered overlaps.
  • A second reviewer checked each overlap.
  • The temporary entry was removed on time.

Could be better

  • The contractual promise was not in the original plan.
  • The first version had no “Pilot” rung in the ladder.
  • The priority map was updated a day late.
DECISION RECORD 01 Accepted
Context

Acme Cart needs a delivery fee that follows plan, staff status, region and app version, with predictable results.

Decision

Use the standard ladder: safety, deliberate exceptions, staff, plans, regions, rollout rings. Write overlaps as sentences, test every overlap, and require review for production lists.

Consequences

Setting up takes more planning, but surprises fall and debugging is quick. The team must keep the priority map current and remove temporary entries on time.

32Real-World and Industry Examples

Ordered, first-match-wins lists are everywhere in engineering and in daily life. Seeing them elsewhere makes Flagsmith’s behaviour feel familiar. The descriptions below are general patterns, not details of any private system.

Network firewalls

Many firewalls hold a list of rules, from top to bottom, and apply the first rule that matches a network packet. Administrators learn quickly that a broad “allow all” rule placed too high makes later “block” rules useless. The advice is the same as in this guide: specific rules first, broad rules last, and review the list regularly.

Web server and routing rules

Web servers and routers often check rewrite or routing rules in order. A rule that catches every address, placed early, hides all rules after it. Teams that run big websites keep these lists short and tested, for the same reasons.

Email filters

Many email programs apply filters in order: “if from my manager, mark as important; if contains the word offer, move to promotions”. When two filters could match, the earlier one wins. Anyone who has seen an important email hidden in a promotions folder has met the problem of priority.

Style rules on web pages

On web pages, the more specific a style rule is, the more it wins over general ones. This is an example of “specific beats general” that developers meet daily, and it mirrors the guidance to place narrow segments above broad ones.

Large product companies and feature gates

Facebook has described internal gating systems that decide who sees a feature using attributes such as employee status and country, usually starting with employees and widening step by step. Netflix and Google have written about careful, staged exposure of changes. In all these systems, clear precedence between groups is part of keeping rollouts predictable.

Airlines and queues

Airlines board passengers by a fixed order of groups, so that no gate agent needs to decide on the spot. The principle of a written, ranked list that anyone can follow is the same.

Laws and contracts

Legal systems often have a rule that a specific provision overrides a general one. Contracts often say which document prevails if two clauses disagree. The pattern gives predictable outcomes when instructions overlap.

SystemOrdered list ofRuleLesson for Flagsmith
FirewallAllow and block rulesFirst match winsBroad rules at the bottom
Website routingRewrite rulesEarly match hides later onesKeep lists short and tested
EmailFiltersEarlier filter winsCheck overlaps
Web stylesStyle rulesSpecific beats generalNarrow above broad
AirlineBoarding groupsFixed orderWrite the ladder down
ContractsDocuments or clausesStated precedenceDocument your priority map
i
Takeaway

Whenever instructions can overlap, mature systems add a clear, written precedence rule. Flagsmith’s ranked list is that rule for feature targeting.

33Reusable Checklists

Experienced pilots do not trust memory for routine steps, and neither should you. Copy these into your team wiki.

Before you add a segment override

  • Write the business rule as a sentence for every overlap with existing entries.
  • Decide the position using the standard ladder.
  • Check the environment and the feature twice.
  • Prepare test users for each overlap.
  • Write the old order and the undo step.

Before you reorder

  • Copy or screenshot the current list.
  • Check for safety entries that must stay on top.
  • Check for identity overrides that may hide the effect.
  • Ask for a review if the environment needs it.
  • Pick a quiet time and tell the people who need to know.

After a change

  • Test every overlap with fake users.
  • Check a few real accounts.
  • Watch error and business graphs for the next hour.
  • Update the priority map and the change log.

When a user reports a surprise

  • Check identity overrides first.
  • Check traits for spelling, type and freshness.
  • List the user’s segments, then read the list from the top.
  • Check the environment key and any cache or refresh delay.
  • Check the audit log for recent edits.

Every quarter

  • Compare real lists with the priority map.
  • Remove entries nobody matches and temporary entries past their date.
  • Compare Staging and Production lists.
  • Review who can edit lists in production.
  • Rehearse a restore of an old order in Staging.
Analogy

A tidy workshop has a hook and a label for every tool. These checklists are the hooks and labels for your ordering.

34Plain-English Glossary

A short reference for the words used in this guide.

Term

Feature flag

A switch outside the code that turns a behaviour on or off.

Term

Environment

A separate set of flag settings for one stage, such as production.

Term

Identity

A record standing for one user.

Term

Trait

One named fact about an identity, such as plan or country.

Term

Segment

A named group defined by rules over traits.

Term

Segment override

A setting for one segment on one feature in one environment.

Term

Identity override

A setting for one named user, checked before segments.

Term

Priority or rank

The position of an override in its list, deciding which match wins.

Term

First match wins

The method of reading a list from the top and using the first entry that fits.

Term

Environment default

The setting used when nothing special matches.

Term

Swallowing

When a broad entry placed higher hides a narrow entry below it.

Term

Overlap

When a user belongs to more than one segment.

Term

Ladder

A standard order of kinds of segments, from safety down to rollouts.

Term

Priority map

A document describing the intended order and its reasons.

Term

Derived trait

A label computed from several facts in your backend.

Term

Percentage split

A stable share of users chosen by a hashed identifier.

Term

Multivariate flag

A flag with several values split by percentages.

Term

Remote evaluation

Flagsmith works out answers on its servers.

Term

Local evaluation

A trusted server downloads the rules and decides by itself.

Term

Audit log

The record of who changed what and when.

35Frequently Asked Questions

Quick answers to the questions that come up most often.

Q1What happens when a user belongs to several segments with overrides on the same feature?
Flagsmith reads the feature’s ranked list from the top and uses the first entry whose segment the user belongs to. Entries below are ignored for that user.
Q2Does the order of conditions inside a segment matter?
No. Conditions inside a rule decide membership, and their order does not change who is a member. Only the order of overrides on a feature matters for priority.
Q3Does a segment have one global priority?
No. Priority belongs to the pairing of a segment with a feature in an environment. The same segment can rank differently in different features and environments.
Q4What beats a segment override?
An identity override for the same feature and the same user. It is checked before the segment list.
Q5What happens when no segment matches?
The environment’s default state and value for the feature are used.
Q6Can two matching segments combine their values?
No. The first match wins and nothing is combined. For a special result for a combination, create a segment for that combination and place it above the two components, or compute a derived trait.
Q7Where does a newly added override land in the list?
It depends on your version, so test it in Staging and write down the answer. Always check the position before saving.
Q8Does reordering in Staging change Production?
No. Each feature in each environment has its own list. Repeat the change in Production on purpose.
Q9Does cloning an environment keep the order?
Cloning generally copies segment overrides, but check in your version by comparing a few lists between the source and the clone.
Q10Is the order the same in local evaluation?
Yes, the same rules apply, but the server uses a downloaded copy that refreshes periodically, so a reorder can reach it a little later.
Q11How should I place a percentage rollout segment?
Below safety rules and paid entitlements, above the default, and with smaller rings above larger ones.
Q12How can I find out why a user got a certain value?
Check identity overrides, the user’s traits and segments, then read the feature’s list from the top, and check the environment and any caches.
Q13Should I use rules like “and not in group X” instead of ordering?
Usually not. Keep segment rules simple and use the order to express who wins. Hidden precedence inside rules is hard to maintain.
Q14Can I require approval to change the order?
On plans that offer approvals, changes to protected environments may need review. Which actions are guarded can differ by version, so test it once and write down the result.

36Summary and Key Takeaways

Let us pull the whole story together in a few lines you can remember.

Key Takeaways

  • First match wins. Flagsmith reads a feature’s ranked segment overrides from the top and uses the first one the user belongs to. Nothing is combined.
  • Three layers of authority. Identity override first, then the ranked segment list, then the environment default.
  • Priority belongs to the pairing. Each feature in each environment has its own list, so orders do not travel by themselves.
  • Membership and priority are different questions. Rules and traits decide who is in a segment. The list decides whose setting wins.
  • Order on purpose. Safety on top, deliberate exceptions next, then staff, plans, regions and temporary rollouts, with narrow groups above broad ones.
  • Test overlaps and keep notes. Use fake users for every overlap, record the old order before each change, and review production lists.
  • Keep lists short and documented. Use a priority map, derived traits and quarterly clean-ups, and verify details of your version in the Flagsmith documentation.