Integration
Experiments & A/B gating
getExperimentVariant and isExperimentEnabled.
Experiments assign visitors to variants server-side. Use the same experimentKey as in the dashboard test creator.
Read assignment
javascript
if (window.Tracuto?.isReady?.()) {
const assignment = window.Tracuto.getExperimentVariant('checkout-header-v2');
if (assignment) {
console.log(assignment.variantId, assignment.variantName, assignment.isControl);
}
if (window.Tracuto.isExperimentEnabled('checkout-header-v2', 'non-control')) {
// Treatment UI
} else if (window.Tracuto.isExperimentEnabled('checkout-header-v2', 'control')) {
// Control / baseline UI
}
}isExperimentEnabled modes
| Mode | Returns true when |
|---|---|
| any-assignment (default) | Visitor is in the experiment (control or treatment) |
| non-control | Assigned to a non-control variant—use for new experience UI |
| control | Assigned to control—use for baseline UI |