My intention
My intention is to NOT let the Facebook pixel receive the Email that is mentioned in the URL string that is the main goal. I would like to solve this by using, for example, Custom Javascript in Google Tag Manager before the Facebook Pixel has been fired.
My question
I am trying to remove the email portion from the URL being given to Facebook through the Facebook Pixel. I am not a developer and the Facebook Pixel is used through GTM. I can see that the above string fires on for example location. href, document.location.href and window.location.href
My problem
URL string that i'd like to modify (note I have removed sensitive parts from the URL):
Code
function removeEmail(url, window.location.href) {
var urlparts = url.split('&Email');{
var prefix = encodeURIComponent(window.location.href) + '&Email';
var pars = urlparts[1].split(/[&;]/g);
return urlparts[0];
}
return url;
}
EDIT (20.02.2020):
- Made some adjustments based on feedback
- Added code (code is based from this question: How can I delete a query string parameter in JavaScript?)
I am aware that the best solution is to fix it in the backend, but the fix in the backend will take a very long time, hence I am looking for a temporary solution in order to be compliant with GDPR, etc.