Meta Ads support is completely optional. If you don’t run Meta Ads, you can skip this entirely.
What This Does
This feature tracks the two Meta events most people care about for paid traffic:InitiateCheckout— when someone clicks a checkout buttonPurchase— when the payment webhook succeeds and the purchase is stored
Why It’s Separate From Analytics
In this repo:- Product analytics live under
lib/analytics/* - Meta checkout attribution lives under
lib/attribution/meta/*
Setup
Get your Meta credentials
You’ll need your Meta Pixel ID and a Conversions API access token from Meta Events Manager.
Restart the app
The Meta Pixel only loads when
NEXT_PUBLIC_ENABLE_META_ATTRIBUTION=true and the required values are present.How the Flow Works
- A user clicks a checkout CTA rendered through
CheckoutLink - The repo sends Meta
InitiateCheckoutin the browser - The payment provider completes checkout
- Your webhook is verified by the shared payment route
- The purchase is stored by the shared payment processor
- The repo sends Meta
Purchasethrough Conversions API
What Meta Receives
The implementation sends:- Product/content identifiers from the shared checkout catalog
- Value and currency
- Hashed user identity data when available
- A stable event ID for purchase deduplication
Key Files
lib/attribution/meta/provider.tsx— Meta provider componentlib/attribution/meta/browser.ts— browser-side pixel eventslib/attribution/meta/conversions-api.ts— server-side Conversions APIcomponents/(ui-components)/payments/checkout-link.tsx— checkout CTA componentlib/payments/processor.ts— where purchase events fire
Verify It Works
Your Meta Ads setup is working if:
- The Meta Pixel loads only when enabled
- Clicking a checkout CTA triggers
InitiateCheckout - A successful purchase webhook triggers
Purchase - Events appear in Meta Events Manager
Pixel loads but no events fire
Pixel loads but no events fire
Make sure your checkout buttons use the
CheckoutLink component, not hardcoded URLs.InitiateCheckout works but Purchase doesn't
InitiateCheckout works but Purchase doesn't
Check that
META_ACCESS_TOKEN is set. The Purchase event goes through the server-side Conversions API, which needs the token.Events don't appear in Events Manager
Events don't appear in Events Manager
Double-check your Pixel ID. Also verify that checkout URLs are present in your env — the Meta feature won’t fire events if there’s nothing to check out.
Payments
See how hosted checkout links and payment webhooks work in the repo.
Analytics
Read about the separate product analytics layer for PostHog, Plausible, and DataFast.

