FB link removing fbclid Ipads IOS

Having a problem my site linking directly from Facebook.

It seems to be caused from the “fbclid” get request query parameter that Facebook is adding to the link.

I have added the below JS

(function() {
var param = 'fbclid';
if (location.search.indexOf(param + '=') !== -1) {
        var replace = '';
        try {
                var url = new URL(location);
                replace = url.href;
        } catch (ex) {
                var regExp = new RegExp('[?&]' + param + '=.*$');
                replace = location.search.replace(regExp, '');
                replace = location.pathname + replace + location.hash;
        history.replaceState(null, '', replace);


This seems to be working for 90% of users but some IOS users are reporting issues.

Is there any reason this wouldn’t work for them?


Some older versions of iOS might not have support for the History API.

It would be gross, but you could just redirect users on the client side using


A better solution would be to rewrite the URL on the server side using the web server or application logic.