We have already published once about an extension that removes several gets from any website that dirty your url: Clean your URLs from Social Network Parameters and Others.
But, today we’re going to show you how to use a basic JavaScript script to remove Facebook’s fbclid
from your website.
Something like this:
https://website.com/index.html?fbclid=IwZXh0bgNhZW0CMTEAAR0-qJHl1VErGqub7nFOmL9OOuFJFJsdnr5yg9xEZA2T1Cc29buSBeBVfzc_aem_qxWU50NfOPAeOYePO2TlzA
This filth that Facebook does, besides being HORRIBLE 🤮, is also disturbing:
Not to mention that this only serves as tracking for them.
To remove, add this code below, before the closing </head>
tag:
<!-- REMOVE fbclid -->
<script>
const url = window.location.href
if(url.match(/fbclid/)){
const new_url = url.replace( new RegExp("\\\?fbclid.*","gm"),"")
history.pushState({}, null, nova_url);
}
</script>
Then just test and no more dirt!
A quick and useful tip for many.