Remove the dirt Facebook makes on your website URL

🗑️ A basic and useful JavaScript code!

Remove the dirt Facebook makes on your website URL

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:

This filth that Facebook does, besides being HORRIBLE 🤮, is also disturbing:

  • When you save the URL in favorites, sometimes it is already saved, but as these codes are dynamic, you end up saving a URL that is already there several times;
  • It also disrupts the site’s statistics services, such as Google Analytics, for example, duplicate occurrences appear.

Not to mention that this only serves as tracking for them.

To remove, add this code below, before the closing </head> tag:

<!-- REMOVE fbclid -->
 const url = window.location.href
 const new_url = url.replace( new RegExp("\\\?fbclid.*","gm"),"")
 history.pushState({}, null, nova_url);

Then just test and no more dirt!

A quick and useful tip for many.

See too:

javascript web


YouTube channel


Marcos Oliveira

Marcos Oliveira

Software developer

Related articles