Skip to content

Instantly share code, notes, and snippets.

@OrenBochman
Last active March 21, 2016 11:46
Show Gist options
  • Save OrenBochman/913f4d0610acc2ae11a2 to your computer and use it in GitHub Desktop.
Save OrenBochman/913f4d0610acc2ae11a2 to your computer and use it in GitHub Desktop.
customising the analytics snippet to clean PII : remove userID from page path.js for standard page reporting
// Checks to see if the current user's userID is found in the URL, if it is, remove it.
var userID = ""; // (Note, this assume the user ID is stored in a variable called `userID`)
if (document.location.pathname.indexOf('user/' + userID) > -1) {
var page = document.location.pathname.replace('user/' + userID, 'user');
ga('send', 'pageview', page);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment