HomeGuidesAPI Reference
Submit Documentation FeedbackJoin Developer CommunityOptimizely GitHubOptimizely NuGetLog In

The purpose of this method is to force a user into a specific variation for a given experiment. The forced variation value doesn't persist across application launches.

## Version

SDK v1.0.0 and higher

## Description

Forces a user into a variation for a given experiment for the lifetime of the Optimizely client. Any future calls to [Activate](🔗), [Is Feature Enabled](🔗), [Get Feature Variable](🔗), and [Track](🔗) for the given user ID returns the forced variation.

Forced bucketing variations take precedence over whitelisted variations, variations saved in a User Profile Service (if one exists), and the normal bucketed variation. Impression and conversion events are still tracked when forced bucketing is enabled.

Variations are overwritten with each set method call. To clear the forced variations so that the normal bucketing flow can occur, use [Remove Variation](🔗) method of passed ExperimentOverridesStore service. To get the variation that has been forced, use [Get Variation](🔗) method of passed ExperimentOverridesStore service.

## Parameters

This table lists the required parameters for the Go SDK.

**overrideKey** _All keys inside object are also required_ExperimentOverrideKeyExperimentOverrideKey contains, - _ExperimentKey (string)_: The key of the experiment to set with the forced variation. - _UserID (string)_: The ID of the user to force into the variation.
**variationKey** _required_stringThe key of the forced variation.

## Example

Creating client with Forced variation service and then setting forced variation:

## See also

[Get Variation](🔗) [Remove Variation](🔗)

## Source files

The language/platform source files containing the implementation for Go is [client.go](🔗).