Force Variation
avsb.forceVariation() lets you manually override which variation of an experiment you see. It is designed for QA testing, debugging, and internal previews — so you can experience exactly what a visitor in any variation sees, without being randomly bucketed.
Method signature
1avsb.forceVariation(experimentId: string, variationId: string) => booleanParameters
experimentIdstringRequiredThe ID of the experiment you want to force. This ID starts with exp_ and can be found in the experiment overview panel, in the experiment URL, and in the A vs B dashboard.
variationIdstringRequiredThe ID of the specific variation you want to apply. Variation IDs start with var_ and are shown on the Variations step of the experiment builder for each variation.
Return value
avsb.forceVariation() returns a boolean:
true— the variation was found and successfully applied. The page will update immediately to show the forced variation.false— either the experiment ID or the variation ID could not be found in the current datafile. Check that the experiment is running and that you have the right IDs.
What happens when you call it
Forcing a variation triggers a sequence of actions in the snippet:
- Deactivates the previous variation — if the visitor is currently in a different variation of the same experiment, its CSS and JS are reversed or removed from the page.
- Updates the visitor cookie — the forced assignment is saved to the
_avsb_visitorcookie so it persists across page loads and browser sessions on the same device. - Injects the new variation— the target variation's CSS is injected into a
<style>tag and its JavaScript is executed. - Sends an exposure event— an exposure is recorded for the forced variation. This affects your experiment's analytics.
When to use it
- QA testing before launch — verify that each variation looks and works correctly on the real website, before the experiment goes live to real visitors.
- Debugging — when something looks wrong in one variation, force yourself into it from the DevTools console to reproduce the issue.
- Internal previews — share a URL with a team member and have them run a DevTools command to see a specific variation without needing a special preview link.
- Stakeholder sign-off — let a product manager or designer force themselves into the variant variation so they can approve the experience before launch.
Code examples
1// Force yourself into variant-a of an experiment2const success = avsb.forceVariation('exp_abc123', 'var_xyz789');3console.log('Force variation:', success ? 'applied' : 'failed');1// Open DevTools, go to the Console tab, and paste this:2avsb.forceVariation('exp_abc123', 'var_xyz789');3// The page will update immediately to show the forced variation1// To go back to the control variation, force the control ID2avsb.forceVariation('exp_abc123', 'var_control');Finding experiment and variation IDs
You need two IDs to call avsb.forceVariation(): the experiment ID and the variation ID.
- Experiment ID — visible in the experiment overview panel, in the browser URL when you are on the experiment page (for example
/projects/123/experiments/exp_abc123), and in the datafile that the snippet downloads. - Variation ID — shown on the Variations step (Step 2) of the experiment builder. Click on any variation to expand it and see its ID.
- The forced variation will persist across page reloads and future visits on the same device and browser.
- The forced exposure is counted in the experiment's analytics, which can skew your results if you are also a real visitor.
_avsb_visitorcookie from DevTools (Application tab → Cookies). This removes all forced assignments and resets your visitor identity. Your next visit will be bucketed randomly like any other new visitor.Resetting forced variations
To clear a forced variation and return to normal random bucketing:
- Open Chrome DevTools (F12 or right-click → Inspect).
- Go to the Applicationtab (you may need to click the ›› arrow to find it in the tab bar).
- Expand Cookiesin the left panel and select your website's domain.
- Find the
_avsb_visitorcookie and click the delete icon next to it. - Reload the page. You will be bucketed into a variation randomly as a fresh new visitor.