rkz / flask-google-optimize

Run server-side experiments in Google Optimize within your Flask app
1 stars 1 forks source link

Customize the weights of the different variations #4

Open rkz opened 7 years ago

rkz commented 7 years ago

Context

For a front-end experiment with N variations, Google Optimize splits 1/N of the traffic on each variation by default. However in the UI it's possible to customize these weights.

In server-side, it expects the server to apply the same weighting.

There is no API to retrieve the weighting configured in Google Optimize.

Goal

In declare_experiment(), allow setting the weights of the variations:

optimize.declare_experiment(
    key='cta_size',
    id='16iQisXuS1qwXDixwB-EWgQ',
    variations={
        0: (None, 0.5),
        1: ('bigger', 0.4),
        2: ('smaller', 0.1)
    }
)

The default weight of a variation is 1 / number of variations and in any case, the sum of weights must equal 1.

When assigning a user to a random variation, do a weighted random pick.