Created
June 3, 2014 15:16
-
-
Save philbar/cbda372be651d415f436 to your computer and use it in GitHub Desktop.
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
<script> | |
function controlVariant() { | |
dataLayer.push({'event': 'google'}); | |
return variantOne; | |
} | |
function testVariant() { | |
dataLayer.push({'event': 'adroll'}); | |
return variantTwo; | |
} | |
var randomNumSample = 1073741824, | |
variantOne = "google", // Variation 1 name | |
variantTwo = "adroll", // Variation 2 name | |
variant = variantOne; | |
if(!{{Split Variation Cookie}} && randomNumSample) { // If cookie isn't set run code | |
if({{Random Number}} < randomNumSample) { | |
variant = testVariant(); // For 50 % of hits, fire Variation 2 | |
} | |
else if({{Random Number}} >= randomNumSample) { | |
variant = controlVariant(); // For 50 % of hits, fire Variation 1 | |
} | |
var d = new Date(); // Create cookie | |
d.setTime(d.getTime()+1000*60*60*24*730); | |
var expires = "expires="+d.toGMTString(); | |
document.cookie = "splitVar="+variant+"; "+expires+"; path=/"; | |
} | |
else if({{Split Variation Cookie}} == variantOne) { // If user has only seen Variation 1 | |
variant = controlVariant(); | |
} | |
else if({{Split Variation Cookie}} == variantTwo) { // If user has only seen Variation 2 | |
variant = testVariant(); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Phil,
I would like to understand your concept and logic about A/B testing for retargeting. Do you use your tag manager script for splitting retargeter audience collector pixels?
Thanks!