cxApi.chooseVariation()总是返回0 [英] cxApi.chooseVariation() always returning 0
问题描述
我的网站是单页网页应用程式。
我正在用我的实验ID加载实验代码:
< script src =// www。 google-analytics.com/cx/api.js?experiment={@js_settings.analytics.experimentid @}>< / script>
在加载完毕后,在显示页面的那一刻,我通过调用函数执行以下操作:
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');
现在,它好像是 cxApi.chooseVariation()
总是返回0.到目前为止,205个会话中的100%被赋予了默认变化(0)。为什么?
问题似乎在于,实验性JavaScript代码需要存在于页面上,即使您手动使用cxApi。你必须修改代码,使它不重定向用户,然后你可以调用chooseVariation(),它会返回一个实际的变化,而不是总是0。
当然这个API应该改进,因为在目前的状态下它最好是平庸的。
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 205 sessions so far were given the default variation (0). Why?
The problem seems to have been that the experiment javascript code is required to be present on the page even if you manually use cxApi. You have to modify the code such that it doesn't redirect the user and then you can call chooseVariation() and it will return an actual variation, instead of always 0.
Surely this API should be improved because in its current state it's mediocre at best.
这篇关于cxApi.chooseVariation()总是返回0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!