Skip to content

Instantly share code, notes, and snippets.

@pwm1991
Created October 28, 2019 12:23
Show Gist options
  • Select an option

  • Save pwm1991/2a5634d24da0c070b1bb74ba90173eba to your computer and use it in GitHub Desktop.

Select an option

Save pwm1991/2a5634d24da0c070b1bb74ba90173eba to your computer and use it in GitHub Desktop.
GTM - removes crap from URLs. Inferior to a custom task.
// Removes URL paramters that are either a) useless or b) store personal data. This is a giant game of whack a mole.
function() {
var params = ['name','fname','lname','first','last','firstname','lastName','lastname','first+name','last+name','your+name','email','emailaddress','email+address','work+email+address'];
var a = document.createElement('a');
a.href = {{Page URL}};
if (a.search) {
qps = '&' + a.search.replace('?', '') + '&';
for (i = 0; i < params.length; i++) {
param = params[i];
iop = qps.indexOf('&' + param + '=');
if(iop > -1) {
ioe = qps.indexOf('&', iop + 1);
qps = qps.slice(0, iop) + qps.slice(ioe, qps.length);
}
}
a.search = qps.slice(1, qps.length - 1);
}
return a.href;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment