开发者

How could I control a set percentage of people that have a specific experience?

I am trying to figure out a way to have say 10% of the traffic to the site have a unique experience (a modal pop-up). In my previous trial I 开发者_如何转开发set up an A/B test with Google Web Optimizer and throttled the experience by creating two versions of the page, one with and one without the modal pop-up scripts. I dont care about the stats, I just want to control the percentage of people that see it.

Can anyone thing of a javaScript solution (no jQuery solutions please, this does not jive well with the old version of Prototype I am stuck with on this site).


function getRandomIntUnder(incount){
return Math.floor(Math.random()*incount);  
}

if(getRandomIntUnder(10)==0){dosomething();}

This isn't time dependent and so should fairly evenly call dosomething() 10% of the time


you could handle this on the server or which javascript. One way to do it would be to get the time, extract the seconds of the current time, and if it is between 0-5 (which is ten percent of a minute), do the magic.

var now = new Date();
var secs = now.getSeconds();

if (secs >= 0 && secs <=5) {
 /// do stuff
}

I think that if you use the interval 0-5, you don't need to first part of my conditional, but you get the point.

I am making the assumption that your traffic is evenly distributed over time, so if that is not the case, this wont work so well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜