Browser SDK
Drop-in analytics for any browser page. Captures page views, clicks, forms, page-leave, rage clicks, and unhandled errors out of the box. Bundles your own custom events through the same transport.
Install
<script
src="https://cdn.jsdelivr.net/npm/@getfluxly/browser@0.5.0/dist/gflux.iife.js"
data-project="gflux_pub_yourkey"
data-host="https://api.getfluxly.com"
crossorigin="anonymous"
></script>
Or as an npm module:
npm install @getfluxly/browser
import { initGFlux } from "@getfluxly/browser";
const gflux = initGFlux({
apiKey: "gflux_pub_yourkey",
apiHost: "https://api.getfluxly.com",
});
Track an event
gflux.track("subscription_started", { plan: "pro" });
Identify a user
gflux.identify("user_42", { plan: "pro", email: "x@y.com" });
After this call the SDK's stored anonymous_id is linked to user_42 on the next ingest. Re-identifying with a different external ID warns and ignores.
Consent
gflux.optIn(); // user accepted tracking
gflux.optOut(); // user declined; SDK stops sending events
The SDK respects navigator.doNotTrack and the GPC signal by default. Override with config.honorDnt = false if your project's posture is "track unless told otherwise".
Configuration
| Option | Default | Notes |
| --- | --- | --- |
| apiKey | (required) | Publishable key, starts gflux_pub_ |
| apiHost | https://api.getfluxly.com | Override for self-hosted or testing |
| flushAt | 20 | Events queued before forced flush |
| flushIntervalMs | 5000 | Periodic flush cadence |
| honorDnt | true | Respect DNT / GPC |
| nonce | none | CSP nonce, if your site uses one |
Bundle size
The IIFE bundle gzips to ~9 KB. Tree-shaken ESM imports go smaller.