Skip to content

Instantly share code, notes, and snippets.

@gesteves

gesteves/nix_utms.js

Created May 27, 2017
Embed
What would you like to do?
Remove UTM parameters from URL after Google Analytics hit
(function() {
var w = window;
var removeUtms = function () {
var location = w.location;
if (location.search.indexOf('utm_') !== -1 && history.replaceState) {
history.replaceState({}, '', window.location.toString().replace(/(\&|\?)utm([_a-z0-9=\.]+)/g, ''));
}
};
ga('send', 'pageview', { 'hitCallback': removeUtms });
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.