Last active
December 18, 2015 05:29
-
-
Save andershaig/5732604 to your computer and use it in GitHub Desktop.
Redirect users with support for referral tracking
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
{% plugin rawtext fanpage_url %} | |
<script type="text/javascript"> | |
if (!document.body.className.match('page_preview')) { | |
var redir; | |
if (window.location.search) { | |
// Triggered if there's already a social referrer being tracked | |
var ref_search = window.location.search; | |
var ref = ref_search.split('='); | |
var ref_id = ref[1]; | |
redir = '{{ fanpage_url }}' + '&app_data' + encodeURIComponent('[social_referrer]=' + ref_id); | |
} else { | |
// Also supports URLs without social referrer | |
redir = '{{ fanpage_url }}'; | |
} | |
// Redirects as soon as possible | |
setInterval( function () { | |
top.location.replace(redir); | |
},100); | |
} | |
</script> |
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
{% plugin rawtext mobile_url %} | |
<script type="text/javascript"> | |
if (!document.body.className.match('page_preview')) { | |
var redir; | |
if (window.location.search) { | |
// Triggered if there's already a social referrer being tracked | |
redir = '{{ mobile_url }}' + window.location.search; | |
} else { | |
// Also supports URLs without social referrer | |
redir = '{{ mobile_url }}'; | |
} | |
// Redirects as soon as possible | |
setInterval( function () { | |
top.location.replace(redir); | |
},100); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment