Documentation

Browser npm package guide

The browser package is a local review artifact and is not published by this workstream. Build/check it with npm --prefix packages/analyticfast run check, then run npm pack ./packages/analyticfast --pack-destination /path/to/temporary-folder from the repository root, choosing an existing folder outside the repository. Install the resulting tarball in your customer project. After the operator publishes it, the public command will be npm install analyticfast; do not install a same-named third-party package before that review.

import { init, track, identify, attribution, consent } from 'analyticfast';
init({ siteId: 'YOUR_SITE_ID', host: 'https://YOUR_ANALYTICS_HOST' });
track('signup_completed', { plan: 'starter' });
identify({ user_id: 'internal-user-id' });
const ids = attribution();

Initialize once in a browser lifecycle hook. If your site has a cookie banner, initialize anyway with consent: 'pending' and call consent(true) when the visitor accepts (see Cookie banners and consent). init({ siteId }) alone assumes the tracker and ingestion endpoint are served on the customer's current origin; pass host for ordinary cross-origin installs. Imports and calls during SSR are safe and do nothing. Init returns a loading/presence boolean, not proof of event receipt. Use Verify installation for that.

The package reuses window.analyticfast and its queue. It does not create its own identity or send duplicate automatic pageviews. Calls made before loading queue up to 100 entries. IDs may be empty before load, after opt-out or when storage is unavailable. Omit unavailable checkout metadata instead of fabricating IDs.

See React, Next.js, Vue, and SvelteKit.

Questions, answered.

How do I use browser npm package with AnalyticFast?

Follow the Browser npm package instructions on this page using your own website’s Site ID and configuration. Verify a real event before relying on the reports.

Where can I get setup help?

Contact support@analyticfast.com with the website domain and a redacted description. Do not send API tokens, signing secrets or personal customer data.