1.0.3 • Published 4 years ago

fb-cookie-clid-extractor v1.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Abouot

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.

TEST

Browse sponcer link from facebook

a facebook sponcer link

Open browser developer console

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: 1. https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/fbp-and-fbc/ 2. https://developers.facebook.com/community/threads/201248874170113/

Script Credit: https://github.com/elbomnetanel

Licence

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.

Buy us a tree