---
metadata:
  - name: generator
    content: Diplodoc Platform v5.54.2
alternate:
  - https://yandex.com/support/varioqub/en/api-usersplit.md
  - https://yandex.com/support/varioqub/ru/api-usersplit.md
  - https://yandex.com/support/varioqub/tr/api-usersplit.md
  - href: en/api-usersplit.md
    type: text/markdown
    title: Markdown version
  - href: llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/support/varioqub/en/llms.txt

# Usersplit API

{% note tip %}

You need developer skills to work with the Usersplit API. If you don't have these skills, contact your website developer or webmaster.

{% endnote %}

The Usersplit API is intended for connecting Varioqub to your site.

## Request format {#request-format}

```bash
GET https://uaas.yandex.ru/v1/exps
  ? [[client_id](*client_id)=<String>]
  & [[url](*url)=<String>]
  & [[i](*i)=<String>]
  & [[client_features](*client_features)=<String>]
  & [[cuid](*cuid)=<String>]
```

#|
|| ##client_id## | Yandex Metrica user ID. Format: `metrika.{counter_id}`. Where `{counter_id}` is the Yandex Metrica tag ID. [How to find the tag number](https://yandex.com/support/metrica/en/general/tag-id.html) ||
|| ##url## | Full URL, including GET parameters, of the page browsed by the user.

If no URL is passed, Varioqub uses the referer from the headers. However, in some cases it may not be possible to send the referer in full or at all. For this reason, we recommend always passing the URL. ||
|| ##i## | Site user's ID stored in first-party cookies. Make sure to set it in the `_ymab_param` cookie upon receiving the response. It may be empty during the user's first visit to the site.

We recommend passing it in each API request. The field may be empty in the first request. ||
|| ##client_features## | Serialized JSON object containing user parameters[*](*parametr). Example: `{"param2": "value2", "param1": "value1"}`. ||
|| ##cuid## | A custom ID that allows you to use your own user IDs in experiments.

To enable this functionality, implement the passing of the GET parameter `cuid` on the site. The value of the parameter needs to correspond to the user ID. The custom ID must not be longer than 30 characters. ||
|#

{% note info %}

The Usersplit API also uses `Referer`, `User-Agent`, and `X-Forwarded-For` to group users by samples. Make sure that they are transmitted correctly.

{% endnote %}

```bash
HEADERS:
Referer: {url}
User-Agent: {user-agent}
X-Forwarded-For: {user_ip}
```

where:

- `url` is the full URL, including GET parameters, of the page browsed by the user.

- `user-agent` is the User-Agent of the site user.

- `user_ip` is the IP address of the site user.

## Response format {#response-format}

#### JSON

```json
{
    "i":"{i}",
    "experiments":"{experiments}",
    "testids": [
        {testid.1},
        ...
        {testid.n}
    ],
    "flags":
    [
        {
            "n":"{flag.1}",
            "v":"{value.1}",
            "t":"{type.1}"
        },
        ...
        {
            "n":"{flag.n}",
            "v":"{value.n}",
            "t":"{type.n}"
        }
    ]
}
```

#|
|| **Field name** | **Description** ||
|| ##i## | Site user's ID stored in first-party cookies. Make sure to set it in the `_ymab_param` cookie upon receiving the response. It may be empty during the user's first visit to the site.
 ||
|| ##experiments## | Technical data for the Yandex Metrica tag is returned in encrypted form. Once received, [pass the data to Yandex Metrica](#experiments) when initializing the tag or by a separate call. ||
|| ##testids## |
<!-- source: en/_includes/objects/testid1.md -->
Array of IDs of variants successfully targeted by the user.
<!-- endsource: en/_includes/objects/testid1.md -->

The value is displayed in the [extended version of Varioqub](https://yandex.com/support/varioqub/en/paid-functionality.md). In the basic version, the array is empty.
 ||
|| ##flags## | Array of flags that define experimental changes. The array consists of `{flag.N}:{value.N}` pairs. Uniqueness of the flags contained in the array isn't guaranteed and depends on how your experiments are configured. ||
|| ##t## | Flag type. It can have the `flag` data type. ||
|| ##n## | Flag name. ||
|| ##v## | Flag value. ||
|#

{% note info %}

The response format may contain additional fields. When processing the response, use only the fields required for working with the API.

{% endnote %}

Response example:

```json
{
    "i":"7ASX7O3PO+SD4f30Y1GqkUEVIgyJ+lqpl9teI7DtiRQTGlsMT8VszxKsrU/2D5+mTTJviiKIv2/2
obmd4t7fGkefkfY=",
    "experiments":"JjfiHndoV8s",
    "flags":
    [
        {
            "n":"flag_name",
            "v":"value",
            "t":"flag"
        }
    ],
     "testids": [
        1234,
        4567
    ],
}
```

## Transmitting technical data to Yandex Metrica {#experiments}

To transmit technical data, use the `experiments` method. You can call this method either when [initializing a tag](https://yandex.com/support/metrica/en/code/counter-initialize.html) or separately.

```javascript
ym(XXXXXX, 'experiments', experiments);
```

| **Parameter** | **Type** | **Description** |
|--------------|--------|-----------|
| ##experiments## | string | Technical data for Yandex Metrica, such as information on the variants used in the experiment. The data is returned in encrypted form after calling the Usersplit API method. |

<!-- source: en/_includes/feedback/feedback.md -->
<details>
    <summary class="button">Contact support</summary>
    <div style="padding: 15px;
     margin: 10px 0;
     background: #FFFFFF;
     border-radius: 10px;
     border: 1px solid var(--yc-color-line-generic);">
     <iframe style="background: #FFFFFF;"
        height="700"
        width="100%"
        frameborder="0"
        src="https://forms.yandex.ru/surveys/1705/?iframe=1&lang=en">
    </iframe>
</details>






<!-- endsource: en/_includes/feedback/feedback.md -->

[*requiredParam]: Required parameter

[*client_id]: Yandex Metrica user ID. Format: `metrika.{counter_id}`. Where `{counter_id}` is the Yandex Metrica tag ID. [How to find the tag number](https://yandex.com/support/metrica/en/general/tag-id.html)

[*url]: Full URL, including GET parameters, of the page browsed by the user.

If no URL is passed, Varioqub uses the referer from the headers. However, in some cases it may not be possible to send the referer in full or at all. For this reason, we recommend always passing the URL.

[*i]: Site user's ID stored in first-party cookies. Make sure to set it in the `_ymab_param` cookie upon receiving the response. It may be empty during the user's first visit to the site.

We recommend passing it in each API request. The field may be empty in the first request.

[*parametr]: To use it in the experiment, activate [the extended version](https://yandex.com/support/varioqub/en/paid-functionality.md).

[*client_features]: Serialized JSON object containing user parameters. Example: `{"param2": "value2", "param1": "value1"}`.

[*cuid]: A custom ID that allows you to use your own user IDs in experiments.
 
To enable this functionality, implement the passing of the GET parameter `cuid` on the site. The value of the parameter needs to correspond to the user ID.