All Collections
Study settings
A/B test 2 or more studies
A/B test 2 or more studies

Learn how to run an A/B test with 2 or more studies using a snippet of Javascript.

Updated over a week ago

Sometimes you'd like to conduct some A/B testing and run 2 or more studies side by side and direct your participants to a random study.

You can do this with a snippet of Javascript to link to your study from your own website with a link you can control. 

All you need to do is:

1. Copy and paste the snippet below into your page where you'd like a link to appear.

2. Change the study URLs to your own, and add more to the comma separated list in the square brackets if you'd like to.

For more advanced customization you probably want to speak nicely to a developer near you.

Here it is:

<script>
 var studies=new Array()

studies[0]="https://bananacom.optimalworkshop.com/optimalsort/bananacomiaredesign";
 studies[1]="https://bananacom.optimalworkshop.com/treejack/bananacom-ia-redesign";
 function optimalWorkshopStudy(){
 window.location=studies[Math.floor(Math.random()*studies.length)];
 }
</script>
<a href="javascript:optimalWorkshopStudy()" title="Thank you for your help">Take the survey now!</a>
Did this answer your question?