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.
In the usertrax dashboard
Section titled “In the usertrax dashboard”Navigate to A/B Tests
- Sign in to your usertrax dashboard
- Go to A/B Tests in the main menu
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”)
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.
- Test key: Unique ID used in code and HTML attributes (e.g.
Add variants and save
At least one control and one treatment variant. Save and activate the test.
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.
Primary goal and traffic split
Section titled “Primary goal and traffic split”Primary goal
Section titled “Primary goal”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.
Traffic split
Section titled “Traffic split”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.
Defining variants
Section titled “Defining variants”// 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.
// Example: Text change{ "key": "variant_urgency", "name": "Urgency Text", "js": "document.querySelector('.cta-text').textContent = 'Only available today!';", "traffic_percentage": 50}JS runs once when the variant is applied. Write defensively (element present? try/catch) — see Best practices.
{ "key": "variant_complete", "name": "Complete Change", "css": ".special-offer { display: block; background: #fbbf24; padding: 10px; }", "js": "document.querySelector('.offer-text').innerHTML = '<strong>Limited Time:</strong> 50% Off!';", "traffic_percentage": 30}CSS and JS can be combined in the same variant. For larger markup differences, HTML variants are often clearer.
Advanced configuration
Section titled “Advanced configuration”// 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 with start and end date{ "test_key": "holiday_promotion", "start_date": "2024-12-01", "end_date": "2024-12-31", "variants": [...]}Plan start/end so you can still reach the planned runtime and minimum sample size — do not stop mid-peak campaign without enough data.
// Test for specific visitor groups{ "test_key": "returning_visitor_test", "audience_rules": { "visitor_type": "returning", "min_sessions": 2 }, "variants": [...]}Narrower audiences need more calendar time for the same sample size. Document the rules in the test name or description.
Pre-launch checklist
Section titled “Pre-launch checklist”- 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