---
metadata:
  - name: generator
    content: Diplodoc Platform v5.64.0
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: https://yandex.com/support/varioqub/en/api-usersplit.md
    type: text/markdown
    title: Markdown version
  - href: https://yandex.com/support/varioqub/en/llms.txt?revision=r21812785
    rel: describedby
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/support/varioqub/en/llms.txt?revision=r21812785

# Usersplit API

{% note tip %}

Developer skills are required to use the Usersplit API. If you don't have experience with coding, consult your site's developer or webmaster.

{% endnote %}

The Usersplit API connects 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 your tag ID](https://yandex.com/support/metrica/en/general/tag-id.html) ||
|| ##url## | The page URL with GET parameters that the user is currently browsing.

If you don't pass a URL, Varioqub uses the header referrer, though the referrer might not be passed or might be passed only partially. Because of this, we recommend 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. This value can be empty during a user's first session on your site.

We recommend passing this parameter in every API request. For the first request, this field may be empty. ||
|| ##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 they're passed correctly.

{% endnote %}

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

where:

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

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

- `user_ip`: 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. Unique flags aren't guaranteed in the array, as this depends on experiment settings. ||
|| ##t## | Flag type (type). It can have the `flag` data type. ||
|| ##n## | Flag name (name). ||
|| ##v## | Flag value (value). ||
|#

{% note info %}

The response format may contain additional fields. When handling the response, process only the parameters necessary 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
    ],
}
```

## Sending 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 about the variants used in the experiment. This data is returned in encrypted form after a Usersplit API method is called. |


<!-- 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 your tag ID](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.