I'm trying to do A/B testing using Google Experiments on a javascript-generated variation elements.
In simpler example, I'm trying to create a button using javascript that has different colors
The HTML is simple
<form id="foo"></form>
The button is generated like this
var color = Math.floor((Math.random() * 10) + 1) % 2 == 1 ? 'red' : 'green';
$("#foo").append("<input type='submit' value='submit' style='background-color:" + color + "'/>")
$("#foo input[type='submit']").on('click', function(e){
_gaq.push(['_trackEvent', 'Cart', 'Submit']);
});
Here's the fiddle.
In my Google Analytics, I use the event 'Cart'->'Submit'
as a conversion goal. I basically want to test which color has the highest conversion.
I can actually put the color in the event tracker, say _gaq.push(['_trackEvent', 'Cart', 'Submit', 'green']);
and do some filtering in the GA console.
I just knew about GA Experiments and I'm trying to learn about it. From what I understand in GA Experiments here, I have to create several pages to test. Is it possible to do this in one page but using different variation on javascript-generated element like above?