Configure Facebook tracking for your ShadcnKit project
ShadcnKit integrates Facebook Pixel for client-side tracking and Facebook Conversion API for server-side tracking. This guide will walk you through the setup process.
async function sendEventToFacebook(eventData: any) { // ... implementation details ...}export async function POST(req: NextRequest) { // ... other code ... case 'checkout.session.completed': // ... other code ... // Send purchase event to Facebook Conversions API if (checkoutSession.currency && checkoutSession.amount_total !== null) { const facebookEventData = { event_name: "Purchase", // ... other event data ... }; await sendEventToFacebook(facebookEventData); } // ... rest of the function ...}
Improved Tracking Accuracy: By using both Pixel and Conversion API, you ensure more accurate event tracking, even with ad blockers or cookie restrictions.
Better Ad Performance: More accurate data leads to better ad targeting and performance.
Compliance: Server-side tracking can help with privacy compliance by giving you more control over what data is sent to Facebook.
Remember to always comply with data protection regulations and obtain necessary user consents for tracking.