- Create a client for the website so that it can resolve flags.
- Create a flag for the header design, and define its schema.
- Use the flag in the website to control the header.
- Create variants of the header.
- Force a variant for a user to test a specific variant.
- Test resolving the flag with an evaluation context.
- Anyone who wants to set up a flag and understand how to use it.
- You need to have a Confidence account.
Choose a Resolution Method That Fits Your Application
You can resolve a Confidence feature flag in two ways: by using Confidence’s managed resolver or hosting your own local resolver. Read more about the resolution options in the documentation.Create a Client
You must associate all feature flags with at least one client. A client can, for example, be a backend service or a website. Clients use flags to deliver different user experiences. To resolve flags, a client must authenticate with Confidence using client credentials.Go to the Clients page
Click Create and name the client
Web client (unless it already exists).Click Create credential
Create a Flag
Flags let Confidence control the behavior of your application. For example, use a flag to control which machine learning model serves a recommendation, the number and size of tiles on a page, or a call to action message and its position on a sign-up page. For this tutorial, create a flag that controls the color and size of a header. To create the flag, follow these steps.Go to Confidence
Click + Create to create a new flag
Name the flag header-redesign
Select Web client in the clients dialog
header-redesign flag. Limiting which flags are available to which
clients is valuable for several reasons. For example, it prevents exposing flags to clients that run in
uncontrolled environments such as mobile apps or server-side web apps. It also saves resources when resolving flags
in batch (for example, at app start) by restricting resolution to only the relevant flags.
Next, you define the schema of the flag. The value of a flag is not just a
single value, but rather a key-value map of properties. To avoid errors and make flags
easier to work with, Confidence requires you to define a schema for
the flag value. The schema describe the shape of the flag value, by defining
properties and their data types.
In this tutorial, your flag controls the design of a header on a website.
The design consists of color and size, so your flag needs to set two properties: color and size.
Click the edit schema button
Click Add property and select string
Name the property color
Click Add property and select int
Name the property size
color and size properties.
Create Variants
The two variants you want to create for the header redesign are black with size 14, and blue with size 16. To do that, follow these steps.Click + Create variant and name it default-style
Enter values for the default style
black as the value for color, and 14 as the value for size.Click Save
Click + Create variant and name it new-style
Enter values for the new style
blue as the value for color, and 16 as the size.Use the Flag
When resolving a flag into a value, you specify a default value. This default value applies if a user doesn’t match or isn’t assigned by a rule. The following sections show how to integrate the Confidence SDKs and set the default value for ourheader-redesign flag to color green and size 10.
Install Dependencies
You first need to install the necessary dependencies.Initialize Confidence
With dependencies installed, you can now create a Confidence provider for your platform and connect it to the OpenFeature SDK. You only need to do this once, preferably on app startup.Access the Flag
You can access the flag and its values using dot notation for nested properties.user_id and the plan this user is on,
in this case premium.
You can use the plan field in the context to create targeted rules. For example, with this
information in the evaluation context, an A/B test can include only users on the premium plan as
its target audience.
This video gives a quick overview how targeting and evaluation contexts work in 2 minutes and 10 seconds.
Force a Variant For a User
To try out a variant, you can force it for a user with a specific user ID. You do this by creating an individual targeting rule on the flag. Individual targeting rules let you target specific attribute values, such as a list of user IDs. For example, you can add the identifiers of your team members so only your team can test the new experience in its early stages. To create an individual targeting rule, follow these steps.Click + Create rule and select Individual targeting
Select new-style as the variant
Enter user_id as the attribute
Type in user-test-id in the Values section and hit enter
Click Save
Enable the rule
Force all Variant For 50% of Employees
You can create a conditional targeting rule with a targeting audience that includes a subset of the users in that audience. For example, you can create a conditional targeting rule that targets 50% of the users in the"plan": "employee" audience. This way, provided
that all employees have their plan set to employee, you can test the new experience
on a subset of your colleagues.
On the flag page
Click + Create rule and select Conditional targeting
Select new-style as the variant
Add attribute criterion
plan as field name with type string and click Add.Set the inclusion rule to be plan is employee
Enter user_id as the randomization unit
Set the allocation to 50%
Click Save
Enable the rule
user-test-id is eligible for the
individual targeting rule, Confidence evaluates eligibility for the second rule for everyone
else. The second rule, in turn, only targets users on the employee plan.
Change the priority of the rules by dragging the rule cards
into the desired order and clicking save.
Resolve Tester
Use the Resolve tester to see if the rule you expect returns a variant. In the Resolve tester, you give an evaluation context and see which rules match and which don’t, together with the reasons why. On the page of your flag, select Test rules at the top of the list of rules. Click Add evaluation context and give the context you want to test to resolve. If you for example have created an individual targeting rule for the user with IDuser-test-id to the new-style variant, you can test that the rule matches by
adding the user_id field with the value user-test-id to the evaluation
context. Click Resolve to confirm that the individual targeting rule succeeds and
returns the new-style variant.
Most of the SDKs also output log messages that redirect you to the resolve tester specifically for the
flag evaluation that the SDK performed.
The link has a message with the prefix:
See resolves for <flagName> in Confidence:To share a specific test run with someone, copy the URL and send it as a link. The link directs them to the Resolve tester with all context data preserved.

