Created
March 24, 2012 01:47
-
-
Save yahelc/2177363 to your computer and use it in GitHub Desktop.
JS Redirects without killing analytics and sourcing
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
var source = location.search; | |
if(document.referrer){ | |
source += "#referrer=" + encodeURIComponent(document.referrer); | |
} | |
window.location = splashurl + source ; |
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
//Before Google Analytics | |
window._gaq = window._gaq || []; | |
var get = (function() { | |
var map = {}; | |
window.location.hash.replace(/[#&]+([^=&]+)=([^&]*)/gi, function(m, k, v) { | |
map[k] = v; | |
}); | |
return map; | |
} ()); | |
if(get.referrer){ | |
_gaq.push(["_setReferrerOverride", decodeURIComponent(get.referrer)]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment