Предметные инструменты · abtest

A/B-тестирование сайта · изменения

abtest_site_abtest_m170_writeИзменение

Создать A/B-тест · Обновить кеш A/B-теста сайта · Удалить A/B-тест.

Действия

В tools/call передайте имя инструмента, значение action и параметры действия во вложенном объекте arguments.

Создать A/B-тест

abtest_add

Сохраняет настроенный тест выключенным. Файлы страниц не создаёт и не копирует.

fields
объект · обязательный параметр
variants
массив · обязательный параметр
confirm
логическое значение · обязательный параметр
Схема параметров JSON
{
  "type": "object",
  "properties": {
    "fields": {
      "type": "object",
      "properties": {
        "site_id": {
          "type": "string",
          "pattern": "^[A-Za-z0-9]{2}$"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 255
        },
        "description": {
          "type": "string",
          "maxLength": 2000
        },
        "duration_days": {
          "type": "integer",
          "minimum": -1,
          "maximum": 3650,
          "description": "0 — ручная остановка, -1 — достаточная выборка, положительное число — дни."
        },
        "traffic_percent": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100
        },
        "minimum_sample": {
          "type": "integer",
          "minimum": 0,
          "maximum": 1000000000
        },
        "sort": {
          "type": "integer",
          "minimum": 0,
          "maximum": 1000000
        }
      },
      "required": [
        "site_id",
        "name"
      ],
      "additionalProperties": false,
      "minProperties": 1
    },
    "variants": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "template",
              "page"
            ]
          },
          "original": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1000
          },
          "alternative": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1000
          }
        },
        "required": [
          "type",
          "original",
          "alternative"
        ],
        "additionalProperties": false
      },
      "minItems": 1,
      "maxItems": 20,
      "uniqueItems": true
    },
    "confirm": {
      "type": "boolean"
    }
  },
  "required": [
    "fields",
    "variants",
    "confirm"
  ],
  "additionalProperties": false
}

Обновить кеш A/B-теста сайта

abtest_cache_clear

Очищает только штатный кеш активного теста выбранного сайта.

site_id
строка · обязательный параметр
confirm
логическое значение · обязательный параметр
Схема параметров JSON
{
  "type": "object",
  "properties": {
    "site_id": {
      "type": "string",
      "pattern": "^[A-Za-z0-9]{2}$"
    },
    "confirm": {
      "type": "boolean"
    }
  },
  "required": [
    "site_id",
    "confirm"
  ],
  "additionalProperties": false
}

Удалить A/B-тест

abtest_delete

Удаляет настройки остановленного теста. Файлы страниц и данные конверсии сохраняются.

test_id
целое число · обязательный параметр
confirm
логическое значение · обязательный параметр
Схема параметров JSON
{
  "type": "object",
  "properties": {
    "test_id": {
      "type": "integer",
      "minimum": 1
    },
    "confirm": {
      "type": "boolean"
    }
  },
  "required": [
    "test_id",
    "confirm"
  ],
  "additionalProperties": false
}

Создать копию страницы для варианта B

abtest_page_copy

Копирует существующий файл страницы через штатный CopyDirFiles в новый каталог /bitrix/abtest/дата/. Проверяет SHA-256 источника и результата. Страница не исполняется; тест не запускается и не меняется.

site_id
строка · обязательный параметр
source
строка · обязательный параметр
expected_source_sha256
строка · обязательный параметр
confirm
логическое значение · обязательный параметр
Схема параметров JSON
{
  "type": "object",
  "properties": {
    "site_id": {
      "type": "string",
      "pattern": "^[A-Za-z0-9]{2}$"
    },
    "source": {
      "type": "string",
      "minLength": 1,
      "maxLength": 1000
    },
    "expected_source_sha256": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "confirm": {
      "type": "boolean"
    }
  },
  "required": [
    "site_id",
    "source",
    "expected_source_sha256",
    "confirm"
  ],
  "additionalProperties": false
}

Запустить A/B-тест

abtest_start

Включает подмену для посетителей выбранного сайта. Нужно подтвердить влияние на живой трафик; другой активный тест этого сайта препятствует запуску.

test_id
целое число · обязательный параметр
allow_live_traffic
логическое значение · обязательный параметр
confirm
логическое значение · обязательный параметр
Схема параметров JSON
{
  "type": "object",
  "properties": {
    "test_id": {
      "type": "integer",
      "minimum": 1
    },
    "allow_live_traffic": {
      "type": "boolean"
    },
    "confirm": {
      "type": "boolean"
    }
  },
  "required": [
    "test_id",
    "allow_live_traffic",
    "confirm"
  ],
  "additionalProperties": false
}

Остановить A/B-тест

abtest_stop

Штатно останавливает выбранный тест и фиксирует текущего пользователя.

test_id
целое число · обязательный параметр
confirm
логическое значение · обязательный параметр
Схема параметров JSON
{
  "type": "object",
  "properties": {
    "test_id": {
      "type": "integer",
      "minimum": 1
    },
    "confirm": {
      "type": "boolean"
    }
  },
  "required": [
    "test_id",
    "confirm"
  ],
  "additionalProperties": false
}

Изменить A/B-тест

abtest_update

Меняет указанные поля; variants заменяет набор целиком. Для активного теста нужны allow_live_traffic=true и текущий expected_fingerprint из abtest_get. Сохраняет состояние запуска и очищает активный кеш сайта.

test_id
целое число · обязательный параметр
fields
объект
variants
массив
allow_live_traffic
логическое значение
expected_fingerprint
строка
confirm
логическое значение · обязательный параметр
Схема параметров JSON
{
  "type": "object",
  "properties": {
    "test_id": {
      "type": "integer",
      "minimum": 1
    },
    "fields": {
      "type": "object",
      "properties": {
        "site_id": {
          "type": "string",
          "pattern": "^[A-Za-z0-9]{2}$"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 255
        },
        "description": {
          "type": "string",
          "maxLength": 2000
        },
        "duration_days": {
          "type": "integer",
          "minimum": -1,
          "maximum": 3650,
          "description": "0 — ручная остановка, -1 — достаточная выборка, положительное число — дни."
        },
        "traffic_percent": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100
        },
        "minimum_sample": {
          "type": "integer",
          "minimum": 0,
          "maximum": 1000000000
        },
        "sort": {
          "type": "integer",
          "minimum": 0,
          "maximum": 1000000
        }
      },
      "required": [],
      "additionalProperties": false,
      "minProperties": 1
    },
    "variants": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "template",
              "page"
            ]
          },
          "original": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1000
          },
          "alternative": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1000
          }
        },
        "required": [
          "type",
          "original",
          "alternative"
        ],
        "additionalProperties": false
      },
      "minItems": 1,
      "maxItems": 20,
      "uniqueItems": true
    },
    "allow_live_traffic": {
      "type": "boolean"
    },
    "expected_fingerprint": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "confirm": {
      "type": "boolean"
    }
  },
  "required": [
    "test_id",
    "confirm"
  ],
  "additionalProperties": false
}