Forum Moderators: Robert Charlton & goodroi
[edited by: brotherhood_of_LAN at 2:53 pm (utc) on Oct 17, 2014]
[edit reason] removed double post and personal link [/edit]
<!-- 3 buttons, all hidden -->
<button id='grpa' style='display:none;'>Buy Now!</button>
<button id='grpb' style='display:none;'>Buy</button>
<button id='grpc' style='display:none;'>Add to Cart</button>
<script>
// using three groups, but you can use as few or as many as you like
var groups = ['grpa', 'grpb', 'grpc'];
var randindex= Math.floor(Math.random() * groups.length);
var selectedgroup = groups[randindex];
// unhide the button for this group
document.getElementById(selectedgroup).style.display = 'block';
// set the split-test-group dimension in GA
ga('set','split-test-group',selectedgroup);
</script>
Will you get the statistical validity of your experiment?
You will have to manually stop your
experiment
Your code assumes that the "ga" function exists.
And you have to set up those custom dimensions anyway