@rivercode/facebook-conversion-api
TypeScript icon, indicating that this package has built-in type declarations

1.1.8 • Public • Published

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' });

Package Sidebar

Install

npm i @rivercode/facebook-conversion-api

Weekly Downloads

247

Version

1.1.8

License

ISC

Unpacked Size

13 kB

Total Files

14

Last publish

Collaborators

  • ovdahlberg