Meta Pixel (Facebook Pixel)
Learn how to use Meta Pixel with c15t.
On this page
Canary Feature
This feature is available in canary releases and may have breaking changes. Use with caution in production. Report issues on GitHub
Meta Pixel (Facebook Pixel) is a popular tracking pixel for marketing purposes. By default c15t will load the script based on marketing
consent.
This script will also persist after consent is revoked. This is because the script has built-in functionality to opt into and out of tracking based on consent, which allows us to not need to load the script again when consent is revoked.
Implementation
Adding the script to c15t
import { metaPixel } from 'c15t/scripts/meta-pixel';
configureConsentManager({
// ...
scripts: [
metaPixel({
pixelId: '123456789012345',
}),
],
});
metaPixelEvent
You can use the metaPixelEvent
function to track events. This is a wrapper around the fbq
function that the Meta Pixel script uses.
To learn more about Meta Pixel's standard events, see the Meta Pixel documentation.
import { metaPixelEvent } from '@c15t/scripts/meta-pixel';
metaPixelEvent('Purchase', { value: 10.0, currency: 'USD' });
Types
MetaPixelOptions
Property
Types
Script
Property
Types
StandardEventParams
Property
Types