npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@webdevavi007/next-conversions-kit

v1.0.0

Published

Plug-and-play Meta Conversions API (CAPI) and Google Ads / GA4 Measurement Protocol hybrid tracking with automatic deduplication and advanced matching for Next.js and Node.js.

Readme

next-conversions-kit 🚀

Zero-Boilerplate Hybrid Conversions Setup for Meta (CAPI) & Google Ads / GA4.
Automatically handles redundant client + server tracking, SHA-256 advanced matching, and deduplication out of the box.


⚡ Quick 3-Step Setup for Any Next.js Website

1. Environment Variables (.env)

Add your credentials to your project's .env:

# Meta (Facebook) Conversions API & Pixel
NEXT_PUBLIC_META_PIXEL_ID=123456789012345
META_ACCESS_TOKEN=EAAG...your_system_user_access_token
META_TEST_EVENT_CODE=       # Optional: e.g. TEST12345 to verify in Meta Events Manager

# Google Ads & Google Analytics 4 (GA4)
NEXT_PUBLIC_GA_MEASUREMENT_ID=G-XXXXXXXXXX
GA4_API_SECRET=your_ga4_measurement_protocol_api_secret
NEXT_PUBLIC_GOOGLE_ADS_ID=AW-XXXXXXXXXX                 # Optional: for standalone Google Ads tag
NEXT_PUBLIC_GOOGLE_ADS_PURCHASE_LABEL=AbCdEfGh          # Optional: purchase conversion action label
NEXT_PUBLIC_GOOGLE_ADS_LEAD_LABEL=                      # Optional: lead conversion action label
NEXT_PUBLIC_GOOGLE_ADS_SIGNUP_LABEL=                    # Optional: sign up conversion action label

2. Add to app/layout.jsx

Mount <ConversionScripts /> and <TrackingProvider />:

import { ConversionScripts, TrackingProvider } from "next-conversions-kit/components";

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <head>
        <ConversionScripts />
      </head>
      <body>
        <TrackingProvider />
        {children}
      </body>
    </html>
  );
}

What this does automatically:

  • Injects Google Tag (gtag.js) with Enhanced Conversions enabled.
  • Injects Meta Pixel (fbq) with <noscript> fallback.
  • Listens to SPA route changes and tracks PageView / page_view seamlessly.
  • Captures ad click parameters (fbclid, gclid, wbraid, gbraid) and sets standard _fbc cookies.

3. Add Hybrid API Route (app/api/conversions/route.js)

Create a one-liner API route:

import { createConversionsHandler } from "next-conversions-kit/server";

export const POST = createConversionsHandler();

🎯 Tracking Events Anywhere in Your App

Import clean tracking helpers anywhere in your client components:

import {
  trackViewContent,
  trackAddToCart,
  trackInitiateCheckout,
  trackAddPaymentInfo,
  trackPurchase,
  trackLead,
  trackContact,
  trackCompleteRegistration,
} from "next-conversions-kit/client";

1. Product View (ViewContent / view_item)

trackViewContent({
  id: "prod_123",
  title: "Premium Smart Pet Tag",
  salePrice: 499,
});

2. Add to Cart (AddToCart / add_to_cart)

trackAddToCart(
  {
    id: "prod_123",
    title: "Premium Smart Pet Tag",
    salePrice: 499,
  },
  1 // quantity
);

3. Initiate Checkout (InitiateCheckout / begin_checkout)

trackInitiateCheckout(cartItems, totalAmount);

4. Add Payment Info (AddPaymentInfo / add_payment_info)

trackAddPaymentInfo(cartItems, totalAmount, "Cashfree / Razorpay / Stripe");

5. Client Purchase (Purchase / purchase)

trackPurchase(order);

6. Lead Generation (Lead / generate_lead)

trackLead("newsletter_subscription", { email: "[email protected]" });
// or
trackContact({ name: "John Doe", email: "[email protected]", subject: "Inquiry" });

7. User Registration (CompleteRegistration / sign_up)

trackCompleteRegistration({ name: "John Doe", email: "[email protected]" });

🔒 Server-Side Tracking (Webhooks / Payment Callbacks)

When a payment webhook fires (Cashfree, Razorpay, Stripe, PayU, COD) on your backend, dispatch a server-side conversion with deduplication:

import { sendUnifiedConversionServer } from "next-conversions-kit/server";

// Inside your webhook or payment status handler:
await sendUnifiedConversionServer({
  eventName: "Purchase",
  eventId: `order_${order.id}`, // Matches client eventId for deduplication!
  userData: {
    email: order.buyer.email,
    phone: order.buyer.phone,
    name: order.buyer.name,
    city: order.address.city,
    state: order.address.state,
    zipCode: order.address.zipCode,
    country: "in",
    fbp: order.tracking?.fbp,
    fbc: order.tracking?.fbc,
    gaClientId: order.tracking?.gaClientId,
  },
  customData: {
    value: order.total,
    currency: "INR",
    content_ids: order.items.map((i) => i.id),
    contents: order.items.map((i) => ({ id: i.id, quantity: i.quantity, item_price: i.price })),
    order_id: order.id,
  },
  googleParams: {
    transaction_id: order.id,
    value: order.total,
    currency: "INR",
  },
});

📦 How to Install / Distribute This Package

You can use this package across all your company's projects in any of the following ways:

Option A: Local / Monorepo reference

npm install ./packages/next-conversions-kit

Option B: Pack as a reusable .tgz file

Run in terminal:

cd packages/next-conversions-kit
npm pack

This generates next-conversions-kit-1.0.0.tgz. You can copy this file to any project and install:

npm install ./path/to/next-conversions-kit-1.0.0.tgz

Option C: Host on GitHub Repo

Push this folder to a GitHub repository (e.g. github.com/your-org/next-conversions-kit), then install anywhere with:

npm install github:your-org/next-conversions-kit

Option D: Publish to NPM (Public or Private)

npm publish --access public
# or npm publish (for private orgs)

Then install anywhere with:

npm install next-conversions-kit