11metrics-pixel-js
v0.1.0
Published
Framework-agnostic loader for the 11metrics tracking pixel. Injects pixel.js, exposes typed init/pageview/track/identify helpers, and queues calls made before the script finishes loading. Use this directly in any bundler-based app, or via a framework adap
Maintainers
Readme
11metrics-pixel-js
Framework-agnostic loader for the 11metrics tracking pixel. Use this directly
in any bundler-based app (Vite, CRA, plain webpack, etc.), or via a framework
adapter such as 11metrics-pixel-next for Next.js.
This package does not reimplement pixel tracking — it injects the real
pixel.js script served by your 11metrics app and gives you a typed API on
top of window._pulse, queueing calls made before the script finishes
loading.
Install
npm install 11metrics-pixel-js(Not yet published — see "Publishing" below.)
Usage
import { init, pageview, track, identify } from '11metrics-pixel-js';
init({
pixelId: 'YOUR_PIXEL_ID', // Settings → Pixel Setup in the 11metrics app
pixelUrl: 'https://app.11metrics.ai', // optional, this is the default
});
// SPA route change (no full page load) — the initial script load already
// covers the first pageview.
pageview();
// Custom event.
track('video_play', { video_id: 'abc123' });
// After login / a gated form. email/phone are hashed client-side.
identify({ email: '[email protected]', first_name: 'Marco' });API
init(config: { pixelId: string; pixelUrl?: string })— injects the pixel script. Safe to call multiple times; only injects once. No-ops on the server.pageview()— manually fire a pageview. Call on every client-side route change.track(name, meta?)— custom event.identify(data)—{ email?, phone?, first_name?, last_name? }.setNetworkConsent(value)— cross-workspace identity opt-in/out.
Notes
- Requires
PIXEL_URL's target app to be running a build withwindow._pulse.pageview()exposed (added alongside this package — seepublic/pixel.js/pixel/pixel.jsin the main app repo). - Consent handling (the cookie banner,
_pulse_consentgating onidentify()/form submits) lives entirely inpixel.jsitself — this wrapper does not duplicate or override it.
Local development
This package isn't published yet. To build/test it locally:
npm install
npm run build
npm testTo develop 11metrics-pixel-next against your local changes here (before
publishing), from ../pixel-next run:
npm install file:../pixel-js --no-save --legacy-peer-deps--no-save keeps package.json pointed at the real ^0.1.0 registry range
(what actually ships to consumers) rather than a filesystem path.
Publishing
npm run build
npm test
npm login # once, with your npm account
npm publish # from this directoryBump version in package.json first if this isn't the first release.
