Analytics
6.1K members online now
6.1K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

cxApi.chooseVariation() always returning 0

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

My site is a single page webapp.

I'm loading the experiment code with my experiment id: 

<script src="//www.google-analytics.com/cx/api.js?experiment={@ js_settings.analytics.experimentid @}"></script>

After all is loaded, at the moment I display the page, I select the right template by calling a function which does the following:

ga('set', 'expId', experiment_id);

var variation = cxApi.getChosenVariation(experiment_id) || cxApi.chooseVariation();

cxApi.setChosenVariation(variation, experiment_id);
ga('set', 'expVar', variation);
ga('set', 'dimension1', variation);

ga('send', 'pageview');

 

Now, it seems like cxApi.chooseVariation() always returns 0. 100% of the 163 sessions so far were given the default variation (0). Why?

Re: cxApi.chooseVariation() always returning 0

Visitor ✭ ✭ ✭
# 2
Visitor ✭ ✭ ✭
Anyone know what can be wrong and cause chooseVariation() to always return 0?

Re: cxApi.chooseVariation() always returning 0

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Surely someone has an idea of what may be wrong here...