Skip to content

sometime fbclid is missing from url when user click on Facebook Ad but as per developer guide we can get it from cookie, so this code will extract fbclid from cookie and add in url with push state

License

Notifications You must be signed in to change notification settings

furqanfreed/facebook-cookie-clid-extractor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

sometime fbclid is missing from url when user click on Facebook Ad but as per developer guide we can get it from cookie, so this code will extract fbclid from cookie and add in url with push state

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published