Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 142620

remove email from URL string Javascript

$
0
0

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&currencynumber=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&currency=578&md5key=022b61cc5d7d3937e2db03b91aa51559&callbackurl=https:%2F%2Fjava-prod-flc.carus.com%2Fcardibsd2%2FDibsD2%2FPayResp&currencyalpha=NOK&lang=no&paytype=VISA&cancelurl=https:%2F%2Fbooking.company.com%2Fbservice%2Fno%2FPaymentReturn%2FRedirect%2Fcancelled&email=remove@this.com

Code i've tried based on following link (tried to modify it):

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

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.


Viewing all articles
Browse latest Browse all 142620

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>