Last active
December 17, 2015 15:19
-
-
Save bmuller/5631082 to your computer and use it in GitHub Desktop.
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
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| // Track conversion if user clicks (default) | |
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| <a class="opbandit" href="/some/video" data-conversion="click"> | |
| Click Here! | |
| </a> | |
| // or | |
| <a class="opbandit" href="/some/video"> | |
| Click Here! | |
| </a> | |
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| // Track conversion only if (1) user clicks and then (2) in JS on another page you explicitly call conversion | |
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| <a class="opbandit" href="/some/video" data-experiment-name="video url" data-conversion="click,explicit"> | |
| Click Here! | |
| </a> | |
| <script type="text/javascript"> | |
| BANDIT.convert("video url") | |
| </script> | |
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| // Track conversion if user shares (regardless of click) | |
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| <a class="opbandit" href="/some/video" data-conversion="share"> | |
| Click Here! | |
| </a> | |
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| // Specify new conversion event type | |
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| BANDIT.newConversion("timeonsite", function(expname) { | |
| // get first page load | |
| var firstPageLoad = BANDIT.getCookie('first-page-load', new Date()); | |
| // set cookie if not set yet | |
| BANDIT.setCookie('first-page-load', firstPageLoad); | |
| var now = new Date(); | |
| // if user is on site for at least 5 minutes | |
| if((now - firstPageLoad) > (60*60*5)) | |
| BANDIT.convert(expname); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment