We were using facebook Click ID
for tracking and found that for some reason clicks coming in through the ads without the fbclid-parameter attached to the url, there would be several reason that it could happen, so to fix this we are using this script which pulls out the fbclid from the cookies (it usually get stored there even though it doesn't appear in the url) and then it reassigns that in the url without reloading (pushState).
So if you are using fbclid
for tracking and yuo are missing some click you can use this script.
see how to open browser developer console and copy paste below code and that should give you same fbclid as given in url.
var cookies = document.cookie
.split(';')
.map(cookie => cookie.split('='))
.reduce((accumulator, [key, value]) => ({ ...accumulator, [key.trim()]: decodeURIComponent(value) }), {});
var fbclick = cookies._fbc;
console.log(fbclick);
References:
- https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/fbp-and-fbc/
- https://developers.facebook.com/community/threads/201248874170113/
Script Credit: https://github.com/elbomnetanel
This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.