-
-
Save mikesurowiec/3871843 to your computer and use it in GitHub Desktop.
Conditional Synapse Embed
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 type="text/javascript"> | |
var onswipeSometimes = function() { | |
var usr = "f"; | |
var numToRedirect = 0.75; // percent of people to redirect | |
var randomNumber = Math.random(); // [0, 1) | |
if (randomNumber <= numToRedirect) { | |
var synapse = 'http://assets.onswipe.com/synapse/on.js?usr=' + usr; | |
var embed = document.createElement('script'); | |
embed.setAttribute('type', 'text/javascript'); | |
embed.setAttribute('id', 'onswipe_synapse'); | |
embed.setAttribute('src', synapse); | |
var parent = document.getElementsByTagName('head')[0]; | |
var first = parent.firstChild; | |
parent.appendChild(embed, first); | |
} | |
}(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment