Skip to content

Feature Flags

Feature flags let you enable or disable functionality for segments of visitors without deploying new code for every change.

A feature flag is an experiment of type feature_flag. Visitors are assigned to a variant, and your application code reads the assignment to decide which code path to run.

Ttoolab handles assignment, exposure tracking, and reporting. Your code handles the feature logic.

Use feature flags for:

  • Gradual rollouts of new features
  • Kill switches for risky changes
  • Internal or beta access for a subset of traffic
  • Long-lived toggles that may not have a clear end date

| | Feature flag | A/B test | | :- | :----------- | :------- | | Purpose | Control feature availability | Compare variant performance | | Duration | Often long-running | Usually time-bound | | Implementation | Code checks getVariant() | DOM changes or URL routing | | Webhook events | feature_flag.created, feature_flag.updated, feature_flag.exposed | experiment.* events |

Both use the same assignment engine under the hood.

  1. Create a new experiment and select type Feature flag.
  2. Set URL rules and traffic allocation.
  3. Create variants (e.g. off as control, on as treatment).
  4. Publish the experiment.
window.ttoolab?.ready(() => {
const variant = window.ttoolab?.getVariant("new-checkout-flag");
if (variant === "on") {
enableNewCheckout();
} else {
enableLegacyCheckout();
}
});

Always wrap flag checks in ttoolab.ready() to ensure assignments are loaded.

When feature flags are created, updated, or exposed, Ttoolab can send:

  • feature_flag.created
  • feature_flag.updated
  • feature_flag.exposed

Configure these in your project’s webhook settings.

  • Code and flag must agree — if your code checks variant === "on" but the dashboard variant key is enabled, the flag will not work.
  • Default to safe — when the pixel fails to load, default to the conservative code path (usually control/off).
  • Avoid nested flags — too many interacting flags make behavior hard to predict.
  • Clean up old flags — remove flag checks from code when a flag is fully rolled out.
  • Do not change variant keys after launch without updating application code.