Skip to content
freeabtest.com

Developers

Build experimentation into your product

One script tag for the browser, a secret key for your backend, and a REST API for results. Assignment is deterministic, so the browser and your server always agree on a visitor's version.

Get started

Four steps to a running test

  1. 1

    Create a workspace

    Sign in and add the domain you will test on. Browser keys only work on the domains you register.

    Add your domain
  2. 2

    Copy your SDK key

    Each project has dev, staging and production environments, each with its own keys.

    Environments and keys
  3. 3

    Add the script tag

    Put the snippet in the head of every page in the test. It starts on its own.

    Install the SDK
  4. 4

    Create and start a test

    Set the variations and goal in the dashboard, check each version with a preview link, then start.

    Start the test
HTML: browser sdk
<script src="https://www.freeabtest.com/sdk.js" data-key="cro_pk_prod_..." async></script>

One script tag assigns visitors, applies versions, handles split URL redirects and counts click, form and page visit goals. The browser SDK is this script tag; there is no package to install.

Integration examples

From the page to your backend

Copied from the docs. Replace the keys with your own from API keys in the dashboard.

Custom events

Count actions that happen in your own code, with an order value for revenue goals. Paid plans.

JavaScript
ABTest.track('signup');
ABTest.track('purchase', { revenue: 49.99 });
track()

Read the version in your code

Render your own component for the visitor’s version, for example in a single-page app.

JavaScript
ABTest.bootstrap().then(function (r) {
  if (r.matched && r.variation_name === 'Variant B') {
    document.body.classList.add('variant-b');
  }
});
bootstrap()

Assign from your server

Use a secret key from your backend. The same visitor ID gets the same version as in the browser.

curl
curl -X POST https://www.freeabtest.com/api/server/assign \
  -H 'Authorization: Bearer cro_sk_prod_...' \
  -H 'Content-Type: application/json' \
  -d '{"experiment_id": "exp_123", "user_id": "user_42"}'
Server-side testing

Read results

Conversion rates, Wilson intervals and the winner, filtered to one environment if you like.

curl
curl 'https://www.freeabtest.com/api/experiments/exp_123/results?environment=prod' \
  -H 'Authorization: Bearer cro_sk_prod_...'
Results endpoint

JavaScript SDK

A small API on window.ABTest

For a standard test you call nothing: the snippet matches the page, assigns the visitor, applies the version and counts goals. These methods are for everything else.

track(eventName, options)
Counts a custom event goal for every running test with that event name, once per visitor. Pass revenue for order value.
Paid plans
trackConversion(experimentId, eventName)
Records a conversion for one test, for the version the visitor sees on this page.
Paid plans
bootstrap()
Matches the page to a running test and returns the visitor’s version. Call it again on route changes in single-page apps.
Every plan
init(options)
Sets the key, the API address or your own user ID when you load the script without data-key.
Every plan
getUserId()
Returns the visitor ID in use, for debugging, joining with your analytics, or erasing one visitor.
Every plan
consent(granted)
With data-consent="required" on the tag, nothing is stored or sent until you call consent(true).
Every plan

SDK calls catch their own errors and log them to the console, so a failure never breaks your page.

REST API

Endpoints by key type

SDK keys call the browser endpoints. Secret keys call the server and management endpoints, and only see their own project. Experiments are created in the dashboard.

Errors

400
Invalid input. The message names the field.
401
Missing, unknown or revoked key.
403
A plan limit was reached, or the action is not allowed for this caller.
404
Not found, including experiments in other projects.
429
Rate limited. Wait for the seconds in Retry-After.
curl: send a conversion from your server
curl -X POST https://www.freeabtest.com/api/server/track \
  -H 'Authorization: Bearer cro_sk_prod_...' \
  -H 'Content-Type: application/json' \
  -d '{"events": [{"experiment_id": "exp_123", "variation_id": "var_b",
    "user_id": "user_42", "event_type": "conversion", "goal_id": "goal_1"}]}'

Keys and environments

Dev, staging and production in every project

Use a dev key locally, a staging key on staging and a production key on the live site. Events carry the environment of the key, so test traffic stays out of real results.

Creating, rotating and revoking keys

SDK key

cro_pk_<env>_...
Where
Browsers and page source
Can call
/api/assign and /api/track
Safe to expose
Yes, it only works on your registered domains

Secret key

cro_sk_<env>_...
Where
Servers only
Can call
Server, experiment and results endpoints for its project
Safe to expose
No. Keep it in your server configuration

Keys are shown once when you create them and stored hashed.

Webhooks

Paid plans

Signed events when a test changes

A JSON POST to your https endpoint, with retries if it fails. Each delivery has a signature header so you can check it came from us.

  • test.winner: A running test found a winner on its primary goal.
  • test.completed: A test was stopped by hand, on schedule or by a rollout.
  • test.srm_warning: The visitor split does not match the weights.
  • quota.reached: Your organization used its monthly tested visitors.
Verify a delivery
Delivery body
{
  "id": "whd_8k2j...",
  "event": "test.winner",
  "created_at": "2026-10-19T08:30:00.000Z",
  "data": {
    "experiment": { "id": "exp_123", "name": "Homepage CTA", "status": "running" },
    "winner": { "variation_id": "var_456", "name": "Variation 1" },
    "visitors": 4210
  }
}

Integrations

Works with the tools you already use

  • Google Tag Manager

    Add the snippet as a custom HTML tag. Test views are pushed to the dataLayer.

    Read the guide
  • WordPress

    Paste the snippet with any header plugin, or use our plugin on paid plans.

    Read the guide
  • Google Analytics 4

    An experience_impression event for each test view, to compare versions in your reports.

    Read the guide
  • Single-page apps

    Call bootstrap on each route change, for example in a React effect.

    Read the guide

All integrations and the plan each needs

Ship your first experiment.

Free plan with 10,000 tested visitors a month and 1 running test. No card needed.

Get your keys