@rivercode/facebook-conversion-api
v1.1.8
Published
Facebook Conversion API Wrapper for Node.js
Downloads
1,163
Maintainers
Readme
Facebook Conversion API
Node.js wrapper for Facebook's Conversion API
Install
npm install @rivercode/facebook-conversion-api
Initiate Facebook Conversion API
// ES6 import or TypeScript
import FacebookConversionAPI from '@rivercode/facebook-conversion-api';
// CommonJS
const FacebookConversionAPI = require('@rivercode/facebook-conversion-api').default;
const FBConversionAPI = new FacebookConversionAPI(
'accessToken',
'pixelId',
['email1', 'email2'], // or null
['phone1', 'phone2'], // or null
'clientIpAddress',
'clientUserAgent',
'fbp', // or null
'fpc', // or null
'debug', // default to false
);
Read more here on how you can get your access token and fbp/fpc identifiers.
ViewContent Event
FBConversionAPI.addProduct('productSku', quantity);
FBConversionAPI.sendEvent('ViewContent', sourceUrl, { value: 1000, currency: 'USD' }, { eventId: 'eventId' });
Add To Cart Event
FBConversionAPI.addProduct('productSku', quantity);
FBConversionAPI.sendEvent('AddToCart', sourceUrl, { value: 1000, currency: 'USD' }, { eventId: 'eventId' });
Initiate Checkout Event
FBConversionAPI.addProduct('productSku', quantity);
FBConversionAPI.sendEvent('InitiateCheckout', sourceUrl, { value: 1000, currency: 'USD' }, { eventId: 'eventId' });
Purchase Event
FBConversionAPI.addProduct('productSku', quantity);
FBConversionAPI.sendEvent('Purchase', sourceUrl, { value: 1000, currency: 'USD' }, { eventId: 'eventId' });