> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kameleoon.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Kameleoon.API.Visitor

> Reference for the Kameleoon.API.Visitor.setVisitorCode method and the Kameleoon.API.CurrentVisit shortcut.

This module provides a shortcut to obtain a reference to the current [Visitor object](https://docs.kameleoon.com/developer-docs/apis/activation-api-js/api-reference/objects/configuration-and-visitor.md#visitor). The Activation API contains a single, unique Visitor object. This module also allows you to override the visitor code.

## setVisitorCode

The `setVisitorCode()` method overrides the Kameleoon VisitorCode, which is a unique identifier randomly generated for every visitor. Ensure that your ID is unique and doesn't exceed 255 characters.

Call this method as early as possible, specifically before Kameleoon triggers any experiments. If you update the VisitorCode after the engine assigns a variation, the engine reassigns the variation.

```javascript theme={null}
 // Setting up the Kameleoon VisitorCode Override

// Initialize the KameleoonQueue if it doesn't exist
window.kameleoonQueue = window.kameleoonQueue || [];

// Push the command to set the VisitorCode with your own ID

 window.kameleoonQueue.push({
    level: "IMMEDIATE",
    command: () => Kameleoon.API.Visitor.setVisitorCode("<USER_ID>")
 });
```

## Kameleoon.API.CurrentVisit

This module provides a shortcut to obtain a reference to the current, in-progress [Visit object](https://docs.kameleoon.com/developer-docs/apis/activation-api-js/api-reference/objects/configuration-and-visitor.md#visit). It references the same object as `Kameleoon.API.Visitor.visits[Kameleoon.API.Visitor.visits.length - 1]`.
