Remove ?fbclid parameter when sharing link from Facebook

When you share a website link on Facebook, it will add a ?fbclid parameter to the end of the URL like this.
This parameter is used to track the source of traffic to your website from Facebook. However, in some cases, this parameter can cause SEO problems on tracking tools like GA4, ahref, Semrush...
The ?fbclid parameter includes the following information:
The ?fbclid parameter makes your URL longer, harder to remember, and harder to share.
?fbclid can be used to track the effectiveness of Facebook advertising campaigns and to understand how users find your website.
However, if you do not have a need to track the link from Facebook, you can remove the ?fbclid parameter. This makes your urls cleaner and prevents the creation of multiple cache versions due to query parameters behind.
To remove the ?fbclid parameter when sharing website links on Facebook, you can use Cloudflare's Redirect Rules tool.
Follow these steps:
1. Go to your Cloudflare admin page.
2. Click Rules → choose Redirect Rules.
3. In the section Single Redirects → Press Create rules.
4. Fill in any field Rule name.
5. In section If... tick the option Custom filter expression.
6. Then select URI Query String → starts with → fill fbclid=
.
Or you can click "Edit expression" and paste this in.
(starts_with(http.request.uri.query, "fbclid="))
7. Next at Then → choose Dynamic → fill http.request.uri.path
→ Select 302 and press Save.
I have chosen 302 (temporary redirect) not 301 (permanent redirect). Because 301 will cache the user's browser. In case you want to revert back to the state keeping the ?fbclid parameter unchanged, it won't work until cache 301 expired.
After completing the steps on the URL from Facebook containing the parameter ?fbclid will redirect to the original URL without query parameters.
Related Articles