fb-cookie-clid-extractor

1.0.3 • Public • Published

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

Package Sidebar

Install

npm i fb-cookie-clid-extractor

Weekly Downloads

7

Version

1.0.3

License

MIT

Unpacked Size

4.63 kB

Total Files

4

Last publish

Collaborators

  • furqanfreed