Created
May 27, 2017 16:56
-
-
Save gesteves/fde75286febd21b32ed778e76f604d17 to your computer and use it in GitHub Desktop.
Remove UTM parameters from URL after Google Analytics hit
This file contains 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
(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