Skip to content

Instantly share code, notes, and snippets.

@yahelc
Created March 24, 2012 01:47
Show Gist options
  • Save yahelc/2177363 to your computer and use it in GitHub Desktop.
Save yahelc/2177363 to your computer and use it in GitHub Desktop.
JS Redirects without killing analytics and sourcing
var source = location.search;
if(document.referrer){
source += "#referrer=" + encodeURIComponent(document.referrer);
}
window.location = splashurl + source ;
//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