cxApi.chooseVariation()总是返回0 [英] cxApi.chooseVariation() always returning 0

查看:283
本文介绍了cxApi.chooseVariation()总是返回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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆