Skip to content

Creating tests

How to create a test in the dashboard and configure variants and targeting. Serving variants on the page is covered in HTML variants and the JavaScript API.

  1. Navigate to A/B Tests

    • Sign in to your usertrax dashboard
    • Go to A/B Tests in the main menu
  2. Create a new test

    • Click Create New Test
    • Enter a descriptive name (visible only to you)
    • Briefly define the test goal (e.g. “CTA color on pricing”)
  3. Test configuration

    • Test key: Unique ID used in code and HTML attributes (e.g. button_color_test). Prefer not to change it after launch.
    • Primary goal: Event name the test is measured against (e.g. purchase). See below.
    • Traffic split: Percentage distribution of visitors across variants. See below.
    • URL targeting (optional): Which pages the test should run on.
  4. Add variants and save

    At least one control and one treatment variant. Save and activate the test.

  5. Wire it on the website

    Use HTML attributes with the same group/variant keys, CSS/JS in the variant config, or getVariant(test_key) in your own code.


The primary goal is the event that analytics uses by default (e.g. purchase, signup, lead).

  • Conversion rate counts sessions with at least one goal event — not individual event counts.
  • You can filter other events later in analytics; for the “official” decision, the primary goal remains authoritative.
  • Set the goal before launch and do not change it mid-run, or you will compare apples to oranges.

Details: Analytics & evaluation.

Percentages control which share of new assignments each variant receives.

  • Variant percentages should sum to 100%.
  • Typical: 50/50 for two variants; with more variants, split evenly or keep control larger.
  • Already assigned sessions keep their variant (sticky) — changing the split mainly affects new sessions.
  • Very uneven splits (e.g. 95/5) take longer until the smaller variant reaches sample size.

// Example: Testing button color
{
"key": "variant_red",
"name": "Red Button",
"css": ".cta-button { background-color: #dc2626 !important; }",
"traffic_percentage": 50
}

The tracker injects the CSS as <style data-ab-test="…"> into <head>. Prefer specific selectors.


// Run test only on specific pages
{
"test_key": "product_page_test",
"url_pattern": "/product/*",
"variants": [...]
}

Useful when the test should only run on product, checkout, or landing pages — avoids unnecessary assignments on irrelevant URLs.


  • Test key and variant keys are final (no rename planned)
  • Primary goal matches an event that actually fires
  • Traffic percentages sum to 100%
  • Control is clearly defined (baseline)
  • Page tested in private mode: getAssignments() shows the expected variant
  • At least one test conversion fired manually and visible in the dashboard