Created
December 20, 2011 14:06
-
-
Save thomasfl/1501670 to your computer and use it in GitHub Desktop.
Simple A/B split testing template.
This file contains hidden or 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
| <html> | |
| <head> | |
| <script language="javascript"> | |
| var regex = /uio_a_b_test=([^\;]+)/; | |
| var match = regex.exec(document.cookie); | |
| if(match === null){ | |
| var randomnumber = Math.floor(Math.random()*100); | |
| var days=14; | |
| var date = new Date(); | |
| date.setTime(date.getTime()+(days*24*60*60*1000)); | |
| expires = "; expires="+date.toGMTString(); | |
| if( randomnumber > 50 ){ | |
| document.cookie = "uio_a_b_test=index_a.html" + expires; | |
| location.replace("index_a.html"); | |
| } else { | |
| document.cookie = "uio_a_b_test=index_b.html" + expires; | |
| location.replace("index_b.html"); | |
| } | |
| } else { | |
| location.replace(match[1]); | |
| } | |
| </script> | |
| <meta http-equiv="refresh" content="1; url=index_a.html"> | |
| </head> | |
| <body> | |
| <a href="index_a.html">Fortsett / Continue</a> | |
| </body> | |
| </html> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Redirects users randomly to two different pages. Uses cookies to redirect users to same page as previously.