Skip to content

Quickstart (5 minutes)

This walkthrough connects two plugins (GA4 and the Meta Pixel) and sends a couple of events. It assumes you’ve already installed @sunwjy/funnel-client.

Funnel calls window.gtag and window.fbq, so those globals must exist first. Add the standard GA4 and Meta Pixel base snippets to your page <head> (the ones each platform gives you in its dashboard). You only need them loaded; Funnel handles the event calls.

import { Funnel } from "@sunwjy/funnel-client";
import { createGA4Plugin } from "@sunwjy/funnel-client/ga4";
import { createMetaPixelPlugin } from "@sunwjy/funnel-client/meta-pixel";
export const funnel = new Funnel({
plugins: [createGA4Plugin(), createMetaPixelPlugin()],
debug: true, // logs each dispatch to the console while you're wiring things up
});

Pass each plugin’s configuration keyed by the plugin name. Runtime config given here wins over anything you passed to the factory.

funnel.initialize({
ga4: { measurementId: "G-XXXXXXXXXX" },
"meta-pixel": { pixelId: "1234567890" },
});

Call track() with a GA4 event name and its parameters. The same call reaches every plugin.

// A page view
funnel.track("page_view", { page_title: "Home" });
// A purchase: GA4 standard parameters
funnel.track("purchase", {
currency: "KRW",
value: 29000,
transaction_id: "T-1",
});

That’s it. With debug: true you’ll see each event logged, and both GA4 and the Meta Pixel will receive their platform-native versions.