Configuration

Every option you can pass to FastStats Web Analytics

All packages share the same set of options. In React you pass them as props on the Analytics component, in Nuxt you set them under the faststats key, and in plain JavaScript you pass them to the WebAnalytics constructor.

Core Options

OptionTypeDefaultDescription
siteKeystringrequiredThe project key that ties events to your FastStats project
baseUrlstringhttps://metrics.faststats.devWhere events, identify calls, vitals and replays are sent
featureFlagsBaseUrlstringhttps://flags.faststats.devWhere feature flag checks are sent
debugbooleanfalseLogs every action to the console
autoTrackbooleantrueStarts tracking automatically. Set to false to start by hand
trackHashbooleanfalseTreats hash changes as page views for hash based routers
cookielessbooleanfalseForces cookieless mode with no stored identifiers

Error Tracking

errorTracking: {
	enabled: true,
}
FieldTypeDefaultDescription
enabledbooleanfalseTurns the tracker on

Read more in Error Tracking.

Web Vitals

webVitals: {
	enabled: true,
	attribution: false,
}
FieldTypeDefaultDescription
enabledbooleanfalseTurns the tracker on
attributionbooleanfalseAdds debug attribution data to each metric

Read more in Web Vitals.

Session Replays

sessionReplays: {
	enabled: true,
},
replayOptions: {
	flushInterval: 5_000,
	maxEvents: 1000,
	maxBatchSizeBytes: 512 * 1024,
}
FieldTypeDefaultDescription
enabledbooleanfalseTurns the recorder on
replayOptions.flushIntervalnumber5000Flush interval in milliseconds
replayOptions.maxEventsnumber1000Flush after this many buffered rrweb events
replayOptions.maxBatchSizeBytesnumber524288Flush after the buffered event payload reaches this size

For masking and recording details see Session Replay.

consent: {
	mode: "granted",
	pendingBehavior: "anonymous",
}
FieldTypeDefaultDescription
mode"pending" | "granted" | "denied""granted"The current consent state
pendingBehavior"anonymous" | "disabled""anonymous"Cookieless tracking while consent is pending, or no tracking at all

Read more in Consent and Cookieless.

Manual Start

When autoTrack is false the SDK does not begin until you call start. This lets you wait for a cookie banner or any other gate.

import { WebAnalytics } from "@faststats/web";

const analytics = new WebAnalytics({
	siteKey: "your_site_key",
	autoTrack: false,
});

// once you are ready
analytics.start();

Disable Tracking on a Device

The SDK checks localStorage for a flag before it sends anything. Set it to opt a single browser out, which is useful for your own devices.

localStorage.setItem("disable-faststats", "true");

Remove the key to turn tracking back on.

On this page