Question

I've been using mt_rand(1,6), which, depending on the random integer generated, a different CSS style would be used (for MVT).

Is there any reason, in terms of the PHP function, why Analytics would say there is a drastic (>5% in some cases) difference in Unique visitors (~5K in total )? I assumed this should be closer to 0.

So, is it more likely that this is the result of some statistic on Google's end and not the fault of php, or is there a better function I should be using?

Was it helpful?

Solution

mt_rand() won't distribute traffic/options evenly. Quite the opposite. It might be that randomly selected options delivers traffic to: 1,1,6,6,6,6,6,6,3

Your best bet is to use a 'round-robin' method, that equally distributes traffic through your MVT (multi-variate testing) - cycling through: 1,2,3,4,5,6 and repeat.

There are many ways to do it in PHP, but simplistically, Pseudo-code would be:

Render v1,
Write increment to file/DB
Render v2,
Write increment to file/DB
etc..
Reaching v6, reset to v1

Applying approximately equal load to each (of 6?) should yield more accurate results as each potential option/version will receive the same. More complex MVT isn't needed here.

Interestingly, where I've used it before, we've always allocated traffic on a % basis (rather than random) as we can make qualified decisions based on the results. If you don't serve each option equally, then you can't compare results!!

Hope this helps further.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top