0.2.0 • Published 1 year ago

@cataline/facebook-pixel v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Facebook Pixel

JavaScript library for Facebook's Pixel tracking

This library enables Facebook Pixel tracking in your client-side application with full TypeScript support.

Install

npm install @cataline/facebook-pixel

Usage

Configure Facebook Pixel at the start of your application and enjoy seamless tracking.

import { facebookPixel } from '@cataline/facebook-pixel'

facebookPixel.init({
  pixelIds: ['PIXEL_ID', 'PIXEL_ID'],
  autoPageView: true, // optional, defaults to true
})

Track Standard Events

Easily track standard events such as leads and purchases.

// Track a Lead event
facebookPixel.trackEvent({ name: 'Lead' })

// Track a Purchase event with additional parameters
facebookPixel.trackEvent({
  name: 'Purchase',
  params: {
    value: 100,
    currency: 'USD',
  },
})

For a complete list of standard events, refer to the Facebook documentation.

Track Custom Events

You can also track custom events tailored to your needs.

// Track a custom event
facebookPixel.trackEventCustom({
  name: 'ProductView',
  params: {
    productId: '123',
  },
})

Explore custom event tracking in the Facebook documentation.

Event Deduplication

Avoid duplicate events effortlessly.

// Track a Lead event with deduplication
facebookPixel.trackEvent({ name: 'Lead', id: 'unique-id' })

Understand event deduplication better through the Facebook documentation.

License

This project is licensed under the MIT License.

0.2.0

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago