Documentation

AI-powered A/B testing. Drop in one script tag — the agent handles split assignment, statistical analysis, and winner calling automatically.

Quick start

1
Register your site
One API call. Returns your site_id and api_key. Save the key — it won't be shown again.
curl -X POST https://cro.meetkai.xyz/api/register \
  -H "Content-Type: application/json" \
  -d '{
    "site_id": "mysite",
    "name":    "My Site",
    "domain":  "mysite.com"
  }'

# Response:
# {
#   "site_id": "mysite",
#   "api_key": "cro_xxxxxxxxxxxx",
#   "script":  "<script src=...></script>"
# }
2
Add the script tag
Paste into your <head>. That's the entire frontend install.
<script src="https://cro.meetkai.xyz/agent.js" data-site="mysite"></script>
Optional — add cro-pending to elements you plan to test to prevent flash of original copy:
<h1 class="hero cro-pending">Your current headline</h1>
3
Create your first test
Use your API key to create a test. Specify which element to swap and what counts as a conversion.
curl -X POST https://cro.meetkai.xyz/api/sites/tests \
  -H "Authorization: Bearer cro_xxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "page_path":           "/",
    "element":             "hero_headline",
    "selector":            "h1.hero",
    "conversion_selector": "a[href=\"/signup\"], .btn-primary",
    "control_copy":        "Your current headline",
    "challenger_copy":     "Your challenger headline",
    "min_days":            7
  }'
4
Watch it run
The agent starts splitting traffic immediately. Check the dashboard for impressions, CVR per variant, and confidence. A winner is called automatically at 95% confidence.

How it works

On page load, agent.js fetches the active test for the current page. It assigns the visitor to a variant via a 30-day cookie, swaps the copy, and logs an impression. If the visitor clicks the conversion selector in the same session, a conversion is logged.

Every 6 hours, a cron job evaluates all active tests. When a test reaches 95% statistical confidence with at least 200 impressions per variant and has run for the minimum days, the winner is called and the test is marked complete.

Only one test runs per page at a time. Multiple pages can have tests simultaneously.

API reference

Register a site

POST /api/register

Body:
  site_id  string  Unique ID for your site (lowercase, alphanumeric, hyphens ok)
  name     string  Human-readable label
  domain   string  Your site domain

Returns: { site_id, api_key, script }

Create a test

POST /api/sites/tests
Authorization: Bearer <api_key>

Body:
  page_path           string  Path to run the test on (e.g. "/", "/pricing")
  element             string  Label for the dashboard (e.g. "hero_headline")
  selector            string  CSS selector of element to swap
  conversion_selector string  CSS selector(s) that trigger a conversion
  control_copy        string  Current copy (shown to ~50% of visitors)
  challenger_copy     string  Challenger copy to test
  min_days            int     Minimum days before winner can be called (default: 7)

Returns: { test_id, status, site_id }

List your tests

GET /api/sites/tests
Authorization: Bearer <api_key>

Returns: array of tests with live CVR data per variant

Test fields

FieldTypeNotes
selectorCSS selectorTargets the element to swap. Must be unique on the page.
conversion_selectorCSS selectorComma-separated selectors. Click on any match = conversion.
min_daysintegerPrevents calling a winner too early. Recommended 7+.
page_pathstringExact path. Use "/" for homepage. Does not support wildcards in v1.
Winner calling: Runs every 6 hours. Threshold: ≥ 95% confidence + ≥ 200 impressions per variant + min_days met. After a winner is called, start a new test with the winning copy as control to continue improving.
One test per page: If you have multiple elements to test on the same page, queue them — run one to completion, then start the next. Running multiple tests simultaneously on the same page produces unreliable data.