Ads and pixels
Meta Pixel
Configure the Meta Pixel
Copy the pixel ID from Meta Events Manager. Remove the original pixel snippet,
its <noscript> tracking image and any tag-manager entry that loads the same
pixel.
Register the scripts
Complete your framework quickstart first. Keep its Inth endpoint, policy, styles and consent UI. Remove the vendor's original script, SDK initializer or tag-manager entry, so the vendor loads only through c15t.
The vendor pages put the helper in src/consent-scripts.ts. If your framework
quickstart already has a scripts array, such as the one in c15t.config.ts
in the Next.js guide, add the helper to that array instead of creating a
second file.
The scripts export is a configuration, not an initializer. Add it to the c15t provider you already have, at the registration
point for your framework below. These are edits to that provider, not a second
provider.
Add the configuration to scripts in c15t.config.ts, next to
next.config.ts:
Keep the rest of your config, such as mode and routePrefix, in the
same call. ConsentRoot reads the config in the browser, so the layout
keeps passing only state. App Router, Pages Router and static export all
read the same file. See
Next.js scripts and embeds.
Options
| Option | Default | Behavior |
|---|---|---|
pixelId | Required | Pixel ID passed to fbq('init', ...). The helper trims it. Empty or whitespace-only values log an error and the script does not load. |
initOptions | None | Object passed as the third argument to fbq('init', ...). |
trackPageView | true | Queues fbq('track', 'PageView') after init. Set false to send page views yourself. |
dataProcessingOptions | None | { options, country?, state? }. Queues fbq('dataProcessingOptions', ...) before init, for example { options: ['LDU'], country: 1, state: 1000 } for Limited Data Use in California. |
scriptSrc | https://connect.facebook.net/en_US/fbevents.js | Loader URL override. A blank value falls back to the default. |
Loading and revocation
metaPixel uses the marketing category. Before marketing is allowed, c15t
defines no fbq function and loads nothing from Meta. When marketing becomes
allowed, the helper queues fbq('consent', 'grant'), the optional data
processing options, init and PageView, then loads fbevents.js.
On revocation the helper keeps the pixel script and calls
fbq('consent', 'revoke'). If the visitor allows marketing again before the
page reloads, it calls fbq('consent', 'grant').
Guard your own fbq calls
The helper sends the pixel's page view. Events your code sends, such as
Purchase or Lead, need their own check. After revocation window.fbq still
exists, so its presence does not mean marketing is allowed. Check the
permission first, then that the pixel has loaded:
Pass the current marketing permission from your framework, for example
useConsent('marketing') in React. @c15t/integrations/meta-pixel also exports
typed wrappers: metaPixelEvent, metaPixelCustomEvent,
metaPixelSingleEvent and metaPixelSingleCustomEvent. They do nothing while
window.fbq is undefined, before the pixel's first setup. They do not check
permission, and after revocation window.fbq still exists, so apply the
permission check before calling them.
Their last argument accepts an event ID string for Conversions API
deduplication.
Verify the Meta Pixel
After you allow marketing, fbevents.js loads and a request to
facebook.com/tr carries ev=PageView. Trigger one guarded event and check
that its tr request appears. Then revoke marketing. Before the reload,
calling trackPurchase sends nothing. With client-side navigation, check that
each route change sends one page view, not two.
Test in a private window with an opt-in policy. Open DevTools Network, disable the cache and filter by the vendor's domain:
- Load the page. No request goes to the vendor before you choose.
- Click Reject, then reload. There is still no vendor request.
- Open Privacy settings and allow the helper's category. The vendor script loads without a page reload.
- Turn the category off again and save. c15t reloads the page, and the new page makes no vendor request.
c15t reloads on revocation because removing a script element does not stop
code that already ran. The vendor's listeners, timers and queued events stay
alive until the page unloads. If you set reloadOnConsentRevoked: false, stop
the vendor yourself. Register a callback-only script whose onConsentChange
calls the vendor's opt-out API, as shown in
custom integrations, and check the
permission before each of your own event calls. The reload does not delete
cookies the vendor already set; see
clear on revocation for your framework.
The helper sets vendor to its script ID, so once you declare that vendor a
visitor can turn it off inside an allowed category. See
vendor consent for your framework. The
consent verification guide covers navigation,
expiry and hosting checks.