Meta Pixel, Conversions API and attribution

How do I remove fbclid from a URL?

fbclid can be stripped in a few lines of JavaScript, and Meta adds it again on every click. Where removing it costs attribution, and where it does not.

Published

You can remove fbclid with the URL API in JavaScript or with a redirect rule on your server, and Meta will add it again on the next click. On ad traffic that removal usually costs you attribution, because the value is what builds the fbc click identifier your server sends back with the Lead. Strip it from the links you publish, keep it on the links Meta sends you.

What fbclid is and where it comes from

You never add fbclid yourself. Meta generates it and passes it with the URL of your website when someone clicks an ad on Facebook or Instagram, and Meta’s documentation on the click identifier says the automatic attachment does not affect the tracking parameters you have set. So your template keeps working next to it, with the utm_ keys and the ad ID in the same URL.

What it is for: building the fbc value that goes out with Conversions API events, written as version.subdomainIndex.creationTime.fbclid. What it is not: an ad identifier. An fbclid says nothing about which ad was clicked until Meta looks it up on its side, so it never replaces {{ad.id}} in your own records. If you need the ad ID on the lead itself, it has to come from your Facebook URL parameters.

The parameter has three properties worth knowing before you touch it:

  • it is case sensitive, so it has to be stored exactly as it arrived;
  • it is long, and it arrives as a single opaque string;
  • it belongs to one visit. Meta is explicit that a URL parameter applies to the visit that came from the ad, so a return visit on its own carries none of it.

Removing it in the browser

The modern way is the URL API, which parses the query string instead of rewriting characters with string replacements. This deletes the key and any duplicate of it, then rewrites the address bar without adding a history entry:

const url = new URL(window.location.href);
const hadFbclid = url.searchParams.has('fbclid');
url.searchParams.delete('fbclid');
if (hadFbclid) {
  window.history.replaceState({}, '', url.pathname + url.search + url.hash);
}

Two details make the difference between a clean removal and a broken one. URLSearchParams.delete removes every occurrence of the key, where a regular expression tends to leave the trailing & behind. And replaceState keeps the person on the same page while the address changes, so a copy of the URL no longer carries a click identifier from someone else’s ad.

Server side, the same thing is a rewrite rule on the tracking domain. Do it in a redirect only if you are sure the parameter reaches your application first, because a redirect that rebuilds the query string drops it before anything can read it. That is the mechanism behind most missing click identifiers: a link shortener, an http to https hop, a CMS redirect or a geo redirect, each one a full request and response that can arrive without the query string.

What you lose when the removal is early

The click identifier is one of the two things Meta matches a lead on, the other being the hashed email and phone from the form. Remove fbclid before your server can read it and the fbc value is never written, so the Conversions API event goes out with less to match, and the delivery system learns less from each lead. The fbc and fbp cookies entry covers the format and how the browser and the server copies compare.

There is a second cost, specific to leads. Once the visitor leaves and comes back on their own, only what you stored on the first visit links the return to the click. A first-party cookie written by your server is that store; a URL parameter that you deleted is not. Any redirect hop is also a chance for the parameter to disappear, which is why a landing page that logs the click on the same domain that serves it keeps more of the value than a chain of hops does.

SituationRemove fbclid?Why
Ad click landing on your lead formnoit builds the fbc sent with the Lead
URL shown in the address bar after the visityes, once storedit is someone else’s click ID and it looks like clutter
Links you share in emails, documents, chatyesthe recipient would inherit an attribution you did not earn
Canonical URL, sitemap, structured datayesa canonical address should be stable
Public organic postsyesno ad click, nothing to keep
Logs and analytics exportskeep the stored copyyou need the value to reconcile the lead

For anything a person can copy and forward, the removal should happen before the link leaves your hands:

  1. Take the URL your landing page reports after a real click on a live ad, not the one typed in Ads Manager.
  2. Parse it with the URL API and delete the fbclid key, so duplicates go too.
  3. Set that clean address as the canonical URL of the landing page.
  4. Use the clean address in your sitemap, in emails and in any link you paste for a colleague.
  5. Keep the parameter that arrived in your own record, not in the link you redistribute.

The last step is the one that needs a decision about where the truth lives. A URL parameter describes one visit and disappears; a stored identifier travels with the lead. That is the design behind server-side tracking, where the click identifier is written to a cookie by your server on your own domain, so it survives the hop and stays attached to the form submission.

DropCPL takes that route: the click lands on the domain that serves the landing page, the click identifier goes into a first-party HttpOnly cookie with no redirect in between, and each lead reaches your system with the ad, the creative and the landing page it came from.

Checking that it still works

After any change to the redirect chain or to the address bar, test the path from the click, not from a pasted URL:

  • Click a live ad on your own phone, in the Facebook app, and confirm the landing page received the parameter. A tag manager preview or the browser console is enough.
  • Submit the form and check that the event leaving your server carries an fbc value and the same event_id as the browser copy.
  • Repeat the visit without clicking the ad, and confirm the stored cookie still links the new session to the old click.
  • Only then remove anything from the address bar.

If the parameter never arrives, the problem is upstream of the removal code: check the redirects and the destination URL before rewriting anything. A short list of the other suspects sits in Meta Pixel, Conversions API and attribution, and fbclid has the definition for the people who will ask what the string in the report is.

Questions on this topic

All questions on this topic →

FAQ

Can I stop Meta from adding fbclid at all?+

No. Meta appends it automatically when someone clicks an ad on Facebook or Instagram, and the parameter is not something you configure. Your own URL parameters are added alongside it without conflict, so the practical question is only whether your landing page keeps it.

Does removing fbclid break Meta attribution?+

If the removal happens before your page can read it, yes. The value is what builds the fbc parameter sent with Conversions API events, so a click that arrives without it leaves Meta less to match on. Removing it after the click has been stored on your side costs nothing.

Is fbclid the same as the fbc value?+

No. The fbc value is built from it, in the form version.subdomainIndex.creationTime.fbclid. The click identifier on its own says nothing about which ad produced it, and it is case sensitive, so store it exactly as it arrived.

Why does my analytics show a page without any fbclid?+

The visit did not come from an ad click, or it came from one that lost its query string on the way. A link shortener, an http to https hop, a CMS redirect or a geo redirect can each rebuild the URL without the parameters.

Ready to find out what
converts, for real?

Free to start.

Start free →