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):
https://booking.company.com/#/no/payment/accepted?postype=ssl¤cynumber=578&authkey=4fe55a1aeb572cc6a252513f8f16d3ac&accepturl=https:%2F%2Fbooking.company.com%2Fbservice%2Fno%2FPaymentReturn%2FRedirect%2Faccepted&amount=5900&decorator=responsive&orderid=dontmindme&merchant=dontmindme&ordertext=Booking%20nr:%209689228&flexwin_cardlogosize=1&statuscode=12&transact=dontmindme&cardnomask=dontmindme&cardexpdate=dontmindme&capturenow=1¤cy=578&md5key=022b61cc5d7d3937e2db03b91aa51559&callbackurl=https:%2F%2Fjava-prod-flc.carus.com%2Fcardibsd2%2FDibsD2%2FPayResp¤cyalpha=NOK&lang=no&paytype=VISA&cancelurl=https:%2F%2Fbooking.company.com%2Fbservice%2Fno%2FPaymentReturn%2FRedirect%2Fcancelled&[email protected]
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.