Skip to content

Commit

Permalink
Rename cookie to adSlot and do some A/B testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Kreeftmeijer committed Jun 7, 2012
1 parent 00c66ec commit dc9407e
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions _layouts/default.html
Expand Up @@ -45,23 +45,21 @@ <h2>{{ page.title }}</h2>


var cookies = {}; var cookies = {};
var pairs = document.cookie.split('; ') var pairs = document.cookie.split('; ')
var cookie; var adSlot;


for(i in pairs) { for(i in pairs) {
pair = pairs[i].split('='); pair = pairs[i].split('=');
if(pair[0] == 'jk-ad') { if(pair[0] == 'jk-ad') {
cookie = pair[1]; adSlot = pair[1];
} }
} }


if(!cookie) { if(!adSlot) {
cookie = new Date().getSeconds() % 2; adSlot = new Date().getSeconds() % 2;
document.cookie = 'jk-ad=' + cookie; document.cookie = 'jk-ad=' + adSlot;
} }


console.log(cookie); document.write(ads[adSlot]);

document.write(ads[cookie]);
</script> </script>
</div> </div>


Expand All @@ -77,6 +75,7 @@ <h2>{{ page.title }}</h2>
var _gaq = _gaq || []; var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12888762-1']); _gaq.push(['_setAccount', 'UA-12888762-1']);
_gaq.push(['_trackPageview']); _gaq.push(['_trackPageview']);
_gaq.push(['_setCustomVar', 1, 'adSlot', adSlot == 1 ? 'Carbon ads' : 'Influads']);


(function() { (function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
Expand Down

0 comments on commit dc9407e

Please sign in to comment.