Skip to content

Instantly share code, notes, and snippets.

@davidlwatsonjr
Last active April 15, 2016 02:27
Show Gist options
  • Save davidlwatsonjr/5437928 to your computer and use it in GitHub Desktop.
Save davidlwatsonjr/5437928 to your computer and use it in GitHub Desktop.
Remove analytics variables from the current page's query string. This allows for cleaner bookmarking, sharing, saving in Readability, etc. More analytics variables will added as they are found. This is minified as I use it as a bookmarklet.
(function() {
var r = ['utm_source', 'utm_campaign', 'utm_medium', 'utm_content', 'utm_hp_ref', 'wpisrc', 'xrs', 'fb_action_ids', 'fb_action_types', 'fb_source', 'action_object_map', 'mcid', 'rmid', 'rrid', 'CIMID'],
e = window.location.search.slice(1),
t = e.split('&'),
n = '?',
i = '';
e: for (p in t) {
for (var s = 0; s < r.length; s++) {
if (t[p].indexOf(r[s] + '=') === 0) {
break e
}
}
n = n + t[p] + '&'
}
n = n.slice(0, -1);
n === '?' && (n = '');
i = window.location.origin + window.location.pathname + n + window.location.hash;
i === window.location.href || (window.location = i)
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment