Configuration

Configure the FastStats Web Analytics core and extensions

React and JavaScript use the same core options. Pass them as props to React’s Analytics component or to JavaScript’s init, createClient, or WebAnalytics constructor. In Nuxt, place them under faststats.

Core Options

OptionTypeDefaultDescription
siteKeystringrequiredProject key that ties events to your FastStats project
baseUrlstringhttps://metrics.faststats.devEndpoint used by analytics and extensions
debugbooleanfalseLogs SDK transport and extension diagnostics
trackHashbooleanfalseIncludes URL hashes and tracks hash-based route changes
cookielessbooleanfalseNever stores an anonymous identifier
consent"anonymous" | "granted" | "denied""granted"Initial consent mode
extensionsreadonly AnalyticsExtension[][]Optional trackers to start with the client

The siteKey is public and safe to include in browser code. baseUrl applies to the core and all built-in extensions.

Extensions

Outbound links, error tracking, Web Vitals, and session replay are separate, tree-shakeable imports. With React or JavaScript, create each extension and add it to the extensions array.

import { Analytics } from "@faststats/react";
import { errorTracking } from "@faststats/react/error";
import { outboundLinks } from "@faststats/react/outbound-links";
import { sessionReplay } from "@faststats/react/replay";
import { webVitals } from "@faststats/react/web-vitals";

<Analytics
	siteKey="your_site_key"
	extensions={[
		outboundLinks(),
		errorTracking(),
		webVitals({ attribution: true }),
		sessionReplay({ recordConsole: true }),
	]}
/>;
import { init } from "@faststats/web";
import { errorTracking } from "@faststats/web/error";
import { outboundLinks } from "@faststats/web/outbound-links";
import { sessionReplay } from "@faststats/web/replay";
import { webVitals } from "@faststats/web/web-vitals";

init({
	siteKey: "your_site_key",
	extensions: [
		outboundLinks(),
		errorTracking(),
		webVitals({ attribution: true }),
		sessionReplay({ recordConsole: true }),
	],
});

Nuxt uses a serializable extensions object and loads the selected extensions for you.

nuxt.config.ts
export default defineNuxtConfig({
	modules: ["@faststats/nuxt"],
	faststats: {
		siteKey: "your_site_key",
		extensions: {
			outboundLinks: true,
			errorTracking: true,
			webVitals: { attribution: true },
			sessionReplay: { recordConsole: true },
		},
	},
});

Use true for default extension settings or an options object to customize an extension. See Error Tracking, Web Vitals, and Session Replay for their options.

Lifecycle

init starts the JavaScript shared client immediately. createClient and the WebAnalytics constructor create independent clients that must be started explicitly.

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

const analytics = createClient({ siteKey: "your_site_key" });
analytics.start();

// Later, remove listeners and stop extensions.
analytics.destroy();

React and Nuxt own this lifecycle and start their clients automatically.