What fbclid is
fbclid is a short code that Meta adds to the address of the landing page after a click on a Meta ad. It helps match a later sale or lead back to the ad. The code is only in the first page's address, so it disappears as soon as the visitor clicks to another page.
Why it matters
Without the click ID, Meta has less to match. Your reports show fewer conversions from Meta than really happened, and the algorithm learns from less data. A first-party cookie keeps the click ID for a set time, so the form or checkout can still send it.
Step 1: Read the parameter in Google Tag Manager
- Create a Custom JavaScript variable that reads
fbclidfrom the page address. - Return the value, or an empty string if there is none.
Step 2: Save it in a first-party cookie
- Create a Custom HTML tag that writes a cookie named
fbclidonly when the variable has a value. - Set the cookie path to
/and an expiry of 90 days. - Fire the tag on All Pages, and only when the visitor accepted the matching cookie choice.
Step 3: Send it with the lead or sale
Add a hidden field to your form, or a parameter to your purchase event, that reads the cookie. Your CRM then stores the click ID next to the lead, and the sale can be sent back to Meta with it.
Consent and privacy
The click ID is personal data in many countries. Only save it when the visitor has accepted the relevant cookie choice, and say so in your privacy policy. Do not store anything else in the same cookie.
Test it
- Open your landing page with
?fbclid=test123at the end of the address. - Browse to another page, then check that the cookie still holds
test123. - Submit a test form, and check that the hidden field carries the value.
Want this set up on your site? Book a free 30-minute call and I will check your tracking with you.
Book a free 30-minute call