Skip to content

Instantly share code, notes, and snippets.

@lukefrake
Last active December 6, 2021 10:29
Show Gist options
  • Save lukefrake/6e46b18c873a01095b5c2c028c56e9aa to your computer and use it in GitHub Desktop.
Save lukefrake/6e46b18c873a01095b5c2c028c56e9aa to your computer and use it in GitHub Desktop.
Google Optimize Mutually Exclusive Experiments with Customer Javascript
// Use in the custom JavaScript section of Google Optimize to generate a group of buckets
// Change the %4 to %n to change the number of buckets
// Buckets are returned 0 index, so the following function will return 0, 1, 2 or 3
function() {
var group = localStorage.getItem('optimizeTestGroup');
if ( group ) return group
group = parseInt(ga.getAll()[0].get('clientId'))%4;
localStorage.setItem('optimizeTestGroup', group)
return group;
}
@lukefrake
Copy link
Author

The following GIF shows how to add this to Google Optimize.

MutuallyExclusiveGroup

@kantradiction
Copy link

How do you define which bucket an optimize experiment is in?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment