Bucketing Visitors into an Experiment and Variation Programmatically

Why would I do this?

Sometimes you might want to decide which visitors see which variation of an experiment based on some custom internal logic. Be sure the population gets splitted in a random fashion as otherwise results might be biased. Example, if you show variation A to only visitors that are new to the site and variation B to only visitors that have at least 5 browsing sessions but did not buy yet, it's probably more likely that B would get a higher conversion rate and eventually win. 

How to bucket the visitor a specific experiment-variation pair?

To do that, just trigger the following javascript code:


window._conv_q = window._conv_q || [];
window._conv_q.push(['assignVariation',"experiment_id","variation_id"]); 

Replace the experiment_id and variation_id with the ids of your experiment and variation respectively. Make sure the above code is fired before the main tracking snippet. When the main snippet runs, the URL targetting rules will be evaluated and if matched, the variation in which visitor was bucketed will be presented to the user.

 

Tip
Have more questions? Submit a request

Comments