This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
} |