---
title: Bucket visitor
slug: web-experimentation/api/FNki-bucket-visitor
docTags: 
createdAt: 2026-08-05T20:56:17.000Z
---

Bucket the visitor into a given variation.

:::hint{type="info"}
**Note**
At this time, once an experiment > variation mapping for a given visitor has been set, it does not change 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  does not change unless the method is used again. However, the visitor could be bucketed into a different experiment next time they visit, if the API is not used again.

### Syntax

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

### Parameters

| Parameter and Type               | Child Attribute                         | Description                                                                                                               |
| -------------------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| **bucketVisitor** *BucketObject* | N/A                                     | An object with the `type` field set to `bucketVisitor`. The other fields are the function arguments.                      |
| **type** *string*                | Child attribute of type `BucketObject`. | The argument indicating that you are using the `bucketVisitor` function. Required.                                        |
| **experimentId** *string*        | Child attribute of type `BucketObject`. | The ID of an experiment you want to bucket a visitor for. Required.                                                       |
| **variationIndex** *integer*     | Child attribute of type `BucketObject`. | The index of the variation you want to bucket the visitor in. Do not use this field when you use the `variationId` field. |
| **variationId** *string*         | Child attribute of type `BucketObject`. | The ID of the variation you want to bucket the visitor in. Do not use this field when you use the `variationIndex` field. |

### Example call

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