Evaluates the specified feature variable of a specific variable type and returns its value.
This method is used to evaluate and return a feature variable. Multiple versions of this method are available and are named according to the data type they return:
[Boolean](🔗)
[Double](🔗)
[Integer](🔗)
[String](🔗)
[JSON](🔗)
This method takes into account the user `attributes
` passed in, to determine if the user is part of the audience that qualifies for the experiment.
### Boolean
Returns the value of the specified Boolean variable.
### Double
Returns the value of the specified double variable.
### Integer
Returns the value of the specified integer variable.
### String
Returns the value of the specified string variable.
### JSON
Returns the value of the specified JSON variable.
## Version
SDK v1.0
## Description
Each of the Get Feature Variable methods follows the same logic as [Is Feature Enabled](🔗):
Evaluate any feature tests running for a user.
Check the default configuration on a rollout.
The default value is returned if neither of these are applicable for the specified user, or if the user is in a variation where the feature is disabled.
Important
Unlike [IsFeatureEnabled](🔗), the Get Feature Variable methods do not trigger an impression event. This means that if you are running a feature test, events will not be counted until you call Is Feature Enabled. If you do not call Is Feature Enabled, you will not see any visitors on your results page.
## Parameters
The table below lists the required and optional parameters in Go.
Parameter | Type | Description |
**featureKey** _required_ | string | The feature key is defined from the Features dashboard; see [Use feature flags](🔗). |
**variableKey** _required_ | string | The key that identifies the feature variable. For more information, see: [Create feature variables](🔗). |
**userContext** _required_ | entities.UserContext | Holds information about the user, such as the userID and the user's attributes. |
## Returns
The value this method returns is determined by your feature flags. This example shows the specific value returned for Go:
API | Return |
GetFeatureVariableBoolean | @return The value of the variable, or `false ` with error if the feature key is invalid, the variable key is invalid, or there is a mismatch with the type of the variable. |
GetFeatureVariableDouble | @return The value of the variable, or `0.0 ` with error if the feature key is invalid, the variable key is invalid, or there is a mismatch with the type of the variable. |
GetFeatureVariableInteger | @return The value of the variable, or `0 ` with error if the feature key is invalid, the variable key is invalid, or there is a mismatch with the type of the variable. |
GetFeatureVariableString | @return The value of the variable, or `empty-string ` with error if the feature key is invalid, the variable key is invalid, or there is a mismatch with the type of the variable. |
## Example
This section shows an example of how you can use the `getFeatureVariableInteger
` method.
## Side effects
The table lists other Optimizely functionality that may be triggered by using this method.
Functionality | Description |
Notifications | Invokes the `DECISION ` "data": {
is this notification is subscribed to. |
The example code below shows how to add and remove a decision listener.
## Exceptions
None
## Source files
The language/platform source files containing the implementation for Go is [Go](🔗).