Feature Flags: A Strategic Guide for Agile Product Rollouts

May 13, 2025

A feature flag is a tool that allows you to enable or disable features in your product without deploying new code each time. Feature flags are ideal for rolling out new functionality gradually, performing quick rollbacks if something fails, or running A/B tests and controlled experiments.

  • They let you modify the product experience for different user segments.
  • You can define what percentage of users will see the new feature.
  • Users can be segmented by properties, cohorts, or custom rules.

Within Amplitude

1. Create a Deployment

A deployment is an environment where feature flags or experiments run (e.g., «web,» «android,» «backend»). This will generate a deployment key, which you’ll use in your code to connect the SDK to Amplitude.

2. Set Up Your Experiment

  • Create a Feature Flag
    Go to Experiment > Feature Flags and click + Create Feature Flag.
    Select the project, name the flag, and define the flag key (a unique identifier used in your code).
  • Configure Variants
    Variants are the possible values of the flag (e.g., «on» and «off»). You can add more if you need different experiences.
  • Define Segments and Rollout Percentage
    A segment is a group of users defined by properties (country, plan, etc.) or cohorts.
    Decide what percentage of each segment will see each variant.
  • Save and Activate the Flag
    Save your configuration, and when ready, activate the flag to start serving it.

Steps Outside Amplitude (In Your Code or Product)

1. Install the Amplitude Experiment SDK

The SDK is a library that lets your application check the status of feature flags. Install it in your project (e.g., using npm for JavaScript or adding the script to your web <head>).

2. Initialize the SDK with Your Deployment Key

Use the deployment key from your deployment to initialize the SDK in your app.

3. Check the Flag Status in Your Code

Use the flag key to query the SDK and determine if the flag is «on,» «off,» or another value, then adjust your product logic accordingly.

4. (Optional) Perform QA Testing

Before rolling out to all users, test the flag with specific users to ensure it works as expected.

Creating a Flag

Prerequisites:

  • A deployment must be created.
  • The Amplitude Experiment SDK must be installed (or you must be ready to use the Evaluation API).

Steps to Create the Flag:

  1. Go to Experiment > Feature Flags in the sidebar.
  2. Click + Create Feature Flag.
  3. Select the project, name the flag, and Amplitude will generate a flag key for your code.
  4. Configure Evaluation & Bucketing:
    • Choose the evaluation mode: Remote (on Amplitude’s servers) or Local.
    • Define the bucketing unit (usually «user,» but could be «company ID» or another property).
  5. Add Variants:
    • Each flag must have at least one variant (e.g., «on» and «off»).
    • Add more variants for different experiences.
    • Assign a name, value, and description to each variant.
  6. Define Segments & Rollout Percentage:
    • In the allocation panel, define which user segments will see the feature (e.g., users from a specific country, cohorts, etc.).
    • Set the percentage of users in each segment who will receive the feature.
  7. Save & QA:
    • Save the flag and perform quality assurance (QA) testing.
  8. Activate the Flag:
    • Click Activate when ready. The feature will then be available to the defined users and segments.

Notes

  • Deployments: Environments where flags/experiments run (e.g., separating web/backend or dev/production).
  • Variants: Possible values of the flag (e.g., «on,» «off,» «beta»).
  • Flag Key: The unique identifier for the feature flag, used in code to check its status.
    • This is the value the SDK returns when querying the flag in your app, which you use to control your product’s logic.

 

Related Articles
Unlock Data-Driven Success: A Step-by-Step Guide to Implementing an Effective Measurement Plan

Unlock Data-Driven Success: A Step-by-Step Guide to Implementing an Effective Measurement Plan

Unlock Business Growth with Essential Metrics: Master Strategic Decisions Using KPIs

Unlock Business Growth with Essential Metrics: Master Strategic Decisions Using KPIs

Female Leadership in Tech: Shaping the Future with Diversity and Boldness

Female Leadership in Tech: Shaping the Future with Diversity and Boldness