Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

The availability of features may depend on your plan type. Contact your Customer Success Manager if you have any questions.

Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
API Reference

Bucket visitor

Bucket the visitor into a given variation ID or index.

Syntax

window["optimizely"].push(bucketVisitor);

Parameters

Parameter and TypeChild AttributeDescription
bucketVisitor
BucketObject
N/AAn object with the type field set to bucketVisitor. The other fields are the function arguments.
type
string
Child attribute of type BucketObjectThe argument indicating that you are using the bucketVisitor function. Required.
experimentId
string
Child attribute of type BucketObjectThe ID of an experiment you want to bucket a visitor for. Required.
variationIndex
integer
Child attribute of type BucketObjectThe index of the variation you want to bucket the visitor in. Don't use this field when you use the variationId field.
variationId
string
Child attribute of type BucketObjectThe ID of the variation you want to bucket the visitor in. Don't use this field when you use the variationIndex field.

Example Call

window["optimizely"].push({
  "type": "bucketVisitor",
  "experimentId": "6661191859",
  "variationIndex": 1
});

Description

Bucket the visitor into a given variation.

📘

Note: At this time, once an experiment --> variation mapping for a given visitor has been set, it won't be changed unless this method is used again. The function can be used by providing either a variationIndex or a variationId.

The association of the experiment to the variation you select won't be changed unless the method is used again. However, the visitor could be bucketed into a different experiment next time they visit, if the API isn't used again.