Last updated • 23 November 2026

How to Set Up the Meta Conversions API & Pixel on Next.js

Send every conversion on your Next.js site to Meta through both the browser Pixel and the server-side Conversions API. One snippet, no tag manager.

Next.js
+
Meta
Next.js
+
Meta
Next.js
+
Meta

Option 1: Setup with your AI Agent using PixelFlow MCP

If you already use an AI agent like Claude, ChatGPT or Cursor, this is the quickest way to set up the Meta Conversions API and pixel on your Next.js site.

Option 2: Set up manually using PixelFlow

Step 1: Add PixelFlow to your Next.js app

These steps only need doing once. Go through them in order.

  1. Create a PixelFlow account: Start a free 7 day trial at pixelflow.so


  2. Choose your platform: Select Something else and click Continue


  3. Add your website URL: Type in your site’s domain, choose your currency and click Continue (note: subdomains are also tracked by default)


  4. Connect Meta: Choose either One-click connect or Enter Pixel details, then click Continue


  5. Add your tracking script: Click Copy and add the snippet to the <head> of your root layout: app/layout.tsx with the App Router, or pages/_document.tsx with the Pages Router


  6. Deploy: Redeploy your site, then open the live URL so PixelFlow can confirm the install.

  1. Create a PixelFlow account: Start a free 7 day trial at pixelflow.so


  2. Choose your platform: Select Something else and click Continue


  3. Add your website URL: Type in your site’s domain, choose your currency and click Continue (note: subdomains are also tracked by default)


  4. Connect Meta: Choose either either One-click connect or Enter Pixel details, then click Continue


  5. Add your tracking script: Click Copy and add the snippet to the <head> of your root layout: app/layout.tsx with the App Router, or pages/_document.tsx with the Pages Router


  6. Deploy: Redeploy your site, then open the live URL so PixelFlow can confirm the install.

Let your coding agent add it. If you build with Claude Code, Cursor or Codex, connect PixelFlow over MCP and ask it to add the snippet to your root layout for you.

Step 2: Track forms, buttons, page loads and 3rd party tools

With the snippet in your root layout, PixelFlow tracks PageViews automatically. To track forms, button clicks, page loads or events from 3rd party platforms like Stripe or Calendly, use any of these:

  1. Open your site in PixelFlow and click Track More events

  1. Choose the event name you'd like to send to Meta (eg. Lead, Contact, Schedule)

  1. Choose how to trigger it (form, button click or 3rd party integration) and complete the steps shown

You can trigger Meta events from your Next.js site in a few ways:

Visual Tagger: click the buttons, links and forms on your Next.js site that should send an event.

URL triggers: send an event when a visitor reaches a page, like your thank-you page.

3rd party integrations: connect apps such as Stripe and Calendly in PixelFlow to pass purchases and bookings on to Meta and your other ad platforms.

Set up with AI: describe the events you want to your AI agent and it sets the triggers up through PixelFlow MCP.

Step 3: Remove any existing Meta Pixel

To stop duplicate events, remove any Meta Pixel you previously added to Next.js.

  1. Search your codebase for fbq( or connect.facebook.net and delete the Meta Pixel code, often in app/layout.tsx, pages/_document.tsx or pages/_app.tsx.


  2. Remove any pixel package such as react-facebook-pixel and the code that calls it.


  3. If you use Google Tag Manager, delete or pause the Meta Pixel tag and publish the container.


  4. In Meta Events Manager, go to your Pixel's Settings and turn off tracking events automatically without code.


  5. Redeploy so the changes go live.

Add more ad platforms in minutes

Meta is just the start. The same script can send your conversions to TikTok, ChatGPT Ads, Snapchat, Pinterest and Reddit, with no extra code.

FAQ

Setting up Meta CAPI on Next.js: FAQ

Setting up Meta CAPI on Next.js: FAQ

Still stuck? Message us and we'll help you finish the setup.

No, PixelFlow already includes the Meta Pixel alongside the Conversions API. Keeping your old Pixel means each event gets counted twice.

In the <head> of your root layout: app/layout.tsx with the App Router, or pages/_document.tsx with the Pages Router. Then redeploy.

Usually within a few minutes in PixelFlow. Events Manager can take up to 40 minutes to update, while Test Events shows them in seconds.

PixelFlow reads the visitor's choice from supported cookie banners and only sends what they've agreed to. See the consent section of the docs for setup.

Yes. The same setup can also send events to TikTok, Snapchat, Pinterest, Reddit and ChatGPT Ads. Connect each platform in PixelFlow.

Smarter, server-side tracking

Start sending accurate conversions today - no tag manager, no code, no developer required.

Compatible with

  • GoHighLevel logo
  • Kajabi logo
  • Stripe logo