Feature Flags
All the different testing, personalize and rollout rules within FME are built on top of "Feature Flags".
As such, the first step is to fetch the particular flag you're looking to implement for, which is done using the getFlag() function.
getFlag()
// returns a flag object
$featureFlag1 = $vwoClient->getFlag(‘feature_key’, $userContext);
Please note that the flag must already be defined in FME for this.
Parameter Definitions
Parameter | Type | Description |
---|---|---|
feature_key Required | String | unique identifier for the particular feature flag that you're implementing. You will see this while creating a feature flag, and you can also find it under 'Settings' for the Feature Flag after creating it. |
userContext Required | Object | Contains information about the current user, including a required unique identifier for each user. Read more about userContext here. |
isEnabled()
// check if flag is enabled, returns true or false
$isFlagEnabled = $getFlag->isEnabled();
After fetching the flag object, you can call the isEnabled() function, which checks if that particular feature flag is enabled for the current user.
This is evaluated based on the different rules and targeting conditions configured with your feature flag.
If the current user satisfies the conditions for any rollout, testing or personalize rule connected to a specific feature flag, isEnabled() will return 'true', or else it will return 'false'.
Updated 3 months ago