TSTrackStack
HomeDocsPricingBlogChangelogSign inGet started
Back to blog
GuidesFebruary 10, 2026·4 min read·TrackStack Team

How to set up Meta CAPI in Next.js without GTM

Skip Google Tag Manager. Wire first-party Meta CAPI in Next.js with an SDK that handles hashing, deduplication, retries, and delivery logs from your existing app code.

  • Meta CAPI
  • Next.js
  • GTM
  • quickstart

On this page

  1. Why GTM frustrates Next.js teams
  2. Install and init
  3. Fire conversion events
  4. Verify in delivery logs
  5. Stripe and webhooks

Problem: Meta CAPI documentation assumes GTM Server-Side or a custom PHP backend. You run Next.js App Router and want events colocated with the code that fires them — not mapped in a tag manager UI.

Why GTM frustrates Next.js teams

GTM was built for marketers injecting scripts without engineering. In App Router, it fights the component model, loads extra JavaScript, and creates a debugging black box.

Server-Side GTM adds containers and variable mapping disconnected from your TypeScript types.

Install and init

Add the SDK, wrap your layout with the provider, and configure Meta pixel ID and access token in the TrackStack dashboard — not in client env vars for secrets.

Follow quickstart for keys, domain allowlist, and first test event.

import { TrackStackProvider, TrackStackPageview } from "@trackstack/sdk";
import { trackstack } from "@/lib/trackstack";

export default function RootLayout({ children }) {
  return (
    <TrackStackProvider instance={trackstack}>
      <TrackStackPageview />
      {children}
    </TrackStackProvider>
  );
}

Fire conversion events

Call capture() with canonical event names. The edge maps SignUp to Meta CompleteRegistration and Purchase to Purchase, hashing email automatically.

Always include eventId if you also run the Meta pixel.

trackstack.capture("SignUp", {
  email: user.email,
  eventId: `signup_${user.id}`,
});

trackstack.capture("Purchase", {
  email: session.customer_email,
  value: session.amount_total / 100,
  currency: session.currency,
  transactionId: session.id,
  eventId: `purchase_${session.id}`,
});

Verify in delivery logs

Open Logs after your first test event. Confirm HTTP 200 from Meta and inspect Event Match Quality indicators.

GTM sends events into a void. An SDK with logs tells you within seconds whether Meta accepted the conversion.

Stripe and webhooks

For purchases confirmed server-side, fire Purchase from the Stripe webhook handler with the same eventId you used client-side when possible. See examples for webhook patterns.

Key takeaways

  • GTM is optional for Meta CAPI — an SDK fits App Router workflows better.
  • Fire conversions from business logic; include `eventId` for browser/server dedup.
  • Delivery logs are the fastest way to confirm Meta accepted your events.

Sources

Official documentation and references cited in this article.

  • Meta — Conversions API overview
  • Meta — Deduplicate pixel and server events
  • Google — Server-side tagging

More in Guides

Guides4 min read

Google Enhanced Conversions for web apps

Enhanced Conversions improves Google's match rate by sending hashed first-party data with each conversion. This guide covers what to hash, where to fire events, and how to verify payloads land.

Read post
Guides4 min read

LinkedIn and TikTok CAPI: a practical overview

Beyond Meta and Google, LinkedIn and TikTok have server-side conversion APIs with their own payload shapes and match keys. Here is what each expects and where teams get stuck.

Read post
Guides4 min read

B2B vs DTC conversion tracking patterns

Pipeline SaaS and e-commerce shops share ad platforms but not conversion logic. Match keys, event timing, and what you optimize for differ — and your tracking setup should reflect that.

Read post

Ready to fix your conversion pipeline?

Install the TrackStack SDK, route events to Meta and Google, and verify delivery from one dashboard.

Get started freeView quickstart

© 2026 TrackStack. First-party conversion infrastructure.

DocsPricingBlogChangelog