Remove ?fbclid parameter when sharing link from Facebook

ARTRU
Remove ?fbclid parameter when sharing link from Facebook

What is the ?fbclid parameter?

When you share a website link on Facebook, it will add a ?fbclid parameter to the end of the URL like this.

Example remove parameter ?fbclid
Example remove parameter ?fbclid

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 ID of the Facebook ad or post that led the user to your website.
  • The ID of the user who clicked the link.
  • The time the user clicked the link.
  • The website the user is visiting when the link is clicked.

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.

How to remove ?fbclid parameter with Cloudflare

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.

Redirect Rules Cloudflare
Redirect Rules Cloudflare

4. Fill in any field Rule name.

5. In section If... tick the option Custom filter expression.

6. Then select URI Query Stringstarts 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.

Remove query parameters fbclid Redirect Rules Cloudflare
Remove query parameters ?fbclid Redirect Rules Cloudflare

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.

COMMENT

Related Articles