What is fbclid? the new facebook parameter

FacebookUrlAds

Facebook Problem Overview


For two days, I have noticed that the URL that I publish on Facebook, there is a parameter is added:
?fbclid=uFCrBkUgEvKg...
To be more precise something like: http://example.com?fbclid=uFCrBkUgEvKg...

Does anyone know what this parameter does?
What is it for and what is the use of the developers?

Thanks for your comments.

Facebook Solutions


Solution 1 - Facebook

I know that gclid, is short for (Google Click Identifier)
It's a unique tracking parameter that Google uses to transfer information between your Google Ads account and your Google Analytics account.

Facebook must be doing the same thing or something similar with fbclid to improve tracking analytics systems.

Solution 2 - Facebook

This helped me: https://greasyfork.org/en/forum/discussion/44083/fbclid-tracking-parameter-attached-by-facebook

Here is cite from the link:

> Put this code in your .htaccess file: > > RewriteCond %{QUERY_STRING} "fbclid=" [NC] > RewriteRule (.) /$1? [R=301,L] > > If you work in WordPress: > > RewriteEngine On > RewriteBase / > RewriteCond %{QUERY_STRING} "fbclid=" [NC] > RewriteRule (.) /$1? [R=301,L] > RewriteCond %{REQUEST_FILENAME} !-f > RewriteCond %{REQUEST_FILENAME} !-d > RewriteRule . /index.php [L]

Solution 3 - Facebook

As I understand it, the parameter is a means of tracking the site visitor so that if your site includes advertising from Facebook, they can customise it to match the recorded browsing habits of the visitor.

The Apache mod_rewrite solution above is problematic because it strips the entire query string. If the URL already had a query string, this will break it. To strip just the fbclid parameter, it's useful to note that Facebook always appends it to a URL, so it's always last. That simplies the mod_rewrite code a little. This is what I do:

# Strip Facebook spyware tokens
RewriteCond %{REQUEST_METHOD} =GET [NC,OR]
RewriteCond %{REQUEST_METHOD} =HEAD [NC]
RewriteCond %{QUERY_STRING} ^(.*)&?fbclid=[^&]+$ [NC]
RewriteRule ^/?(.*)$ /$1?%1 [NE,L,R=301,E=limitcache:1]
Header always set Cache-Control "max-age=604800" env=limitcache

The E=limitcache:1 flag and Header directive is to limit how long the 301 redirect is cached. By default many browsers cache it literally forever. This reduces that to one week (or 604,800 seconds). I may be in a minority in thinking this, but that seems good practice to me. I don't know how long fbclid tokens persist, but if they're long-lasting, it means Facebook will be directing visitors to the same URLs for a long time, and if you ever want to support Facebook's targeted adverts, or if they start using the fbclid for other functionality that you need, you may find these permanently-cached redirects come back to bite. But if you're willing to risk it, you can delete both the Header directive and the E=limitcache:1 flag.

The two tests of %{REQUEST_METHOD} are to prevent Apache from redirecting POST requests (or more esoteric requests like PUT or DELETE, if they're relevant). Most browsers change the request to be a GET requests on a 301 or 302 redirect, which is explicitly allowed by RFC 7231. There is a new 308 redirect code must not have its method rewritten, but unfortunately it's not supported by Internet Explorer on Windows 7 (and probably never will be).

Solution 4 - Facebook

Another approach, how to remove this parameter (so your users can share your URL without removing it manually) is to use JavaScript and history.replaceState.

All credits go to original author - https://www.michalspacek.cz/zmena-url-a-skryvani-fbclid-pomoci-javascriptu

Code from link:

(function() {
        var param = 'fbclid';
        if (location.search.indexOf(param + '=') !== -1) {
                var replace = '';
                try {
                        var url = new URL(location);
                        url.searchParams.delete(param);
                        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);
        }
})();

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRafael DoradoView Question on Stackoverflow
Solution 1 - FacebookMarcin MilowskiView Answer on Stackoverflow
Solution 2 - Facebookno one specialView Answer on Stackoverflow
Solution 3 - FacebookRichard SmithView Answer on Stackoverflow
Solution 4 - FacebookPavel ŠtěrbaView Answer on Stackoverflow