Keep ratio of A/B testing

Hi all,

I want to implementing A/B testing using Netlify edge function.

I see example in Set up an AB Test | Edge Functions on Netlify
In the example, use random 0 or 1, and 0.5 weighting to manage traffic splitting
But I think this approach is not enough to keep traffic ratio of each version to be 50:50

Since edge function can’t access filesystem, and to make an API request (I think) wouldn’t be a good idea in terms of speed.

anyone have any ideas for this problem? or is my opinion wrong?

Thanks in advance!

Hi @rrums :wave:t6: , welcome to the community! f you need more control over the traffic ratio, you can modify the approach to achieve your desired split. Here’s two possible solution:

  1. You can try to generate a random integer between 1 and 100. This allows for more granularity in the traffic split.
  2. Set a threshold value to define the traffic ratio. For example, if the random number generated is < or = to the threshold, direct the traffic to version A and the other traffic to version B.