-
Notifications
You must be signed in to change notification settings - Fork 3
running features
Features are resolved through variations of relevant experiences. When you run a feature, the SDK finds all experiences whose variations include a fullStackFeature change linked to that feature, evaluates targeting rules, buckets the visitor, and returns the resolved feature status and variable values. See the data model for the full resolution chain.
Returns a single feature's status and variable values for the current visitor.
const feature = userContext.runFeature('feature-key');
// With attributes and experience filter:
const feature = userContext.runFeature('feature-key', {
locationProperties: { url: '/settings' },
visitorProperties: { role: 'admin' },
typeCasting: true,
experienceKeys: ['specific-experience-key']
});Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| featureKey | string | Yes | The feature's unique key |
| attributes | object | No | Bucketing attributes (see creating a user context for the full attributes reference), plus: |
typeCasting (boolean) -- auto-convert values to the variable's defined type (default: true) |
|||
experienceKeys (string[]) -- limit evaluation to specific experiences only |
Returns all features with their status and variable values for the current visitor.
const features = userContext.runFeatures();
// With attributes:
const features = userContext.runFeatures({
locationProperties: { url: '/dashboard' },
visitorProperties: { tier: 'premium' },
typeCasting: true
});Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| attributes | object | No | Bucketing attributes (see creating a user context for the full attributes reference), plus typeCasting (boolean, default: true) |
Returns: An array of BucketedFeature objects.
Each resolved feature is returned as a BucketedFeature with the following fields:
| Field | Type | Description |
|---|---|---|
featureId |
string | The feature ID |
featureKey |
string | The feature key |
status |
string / FeatureStatus |
"enabled" or "disabled" (PHP uses the FeatureStatus enum) |
variables |
object / array | The feature variables with their resolved values |
End-to-end flow: initialize the SDK, create a user context, run a feature, and check its status and variables.
import type {
ConvertInterface, ConvertConfig, ContextInterface, BucketedFeature
} from '@convertcom/js-sdk';
import ConvertSDK from '@convertcom/js-sdk';
const convertSDK = new ConvertSDK({
sdkKey: 'xxx'
});
convertSDK.onReady().then(() => {
const context = convertSDK.createContext('user-unique-id');
const feature = context.runFeature('feature-key');
if (feature && feature.status === 'enabled') {
console.log('Feature is enabled with variables:', feature.variables);
}
});Copyrights © 2025 All Rights Reserved by Convert Insights, Inc.
Getting Started
JavaScript SDK
Core Concepts
- Experiences & Variations
- Feature Flags
- Bucketing Algorithm
- Rule Evaluation
- Segments
- Data Management
- Event System
- API Communication
How-To Guides
- Running Experiences
- Running Features
- Tracking Conversions
- Visitor Context
- Persistent DataStore
- Client-Side Experimentation
- Server-Side Experimentation
- Tracking Script → SDK
- Troubleshooting
Edge & Integrations
Contributing