JavaScript web configuration
Configure the JavaScript web SDK in three places: startup options in init, runtime updates with set_config, and remote toggles in project settings. See PostHogConfig for every option, default, and snapshot date.
Build an init config
Select the options your app needs to generate a startup snippet:
Where settings apply
Pass initial options at page load, so attribution fields like UTM tags and referrer URLs aren't lost. Use set_config for changes later in the session, such as consent state:
PostHog fetches your remote project settings right after startup. Explicit values you pass to init win for heatmaps, web vitals, and exception autocapture.
Session Replay and autocapture run only when both your code and project settings keep them turned on.
Route through a proxy
Standard reverse proxy setups override api_host and ui_host (plus asset_host if your proxy handles only API routes). When your proxy uses custom path prefixes rather than PostHog's default paths, rewrite outbound request paths with rewriteRequestPath:
Pin HTML snippet versions
The default HTML snippet loads /static/array.js, which stays on the latest v1 release.
Edit that path only for an explicit major pin or exact release rollback. Remove exact pins once debugging ends, so updates resume:
If you serve pinned scripts through a CDN or proxy, set strict_script_versioning, so extension scripts use immutable versioned paths too. See keeping SDKs current and Security.
Attach tracing headers
Pass backend hostnames in tracing_headers (hostnames only, no protocol or path) to attach user and session headers to matching fetch and XHR requests:
Product and advanced options
- Autocapture and rageclicks. Configure element ignores, URL allowlists, and thresholds in the autocapture docs, AutocaptureConfig, and RageclickConfig.
- Logs, metrics, and traces. Configure console log capture, OTLP attributes, and network timing in the JavaScript web logs guide, the JavaScript web metrics guide, distributed tracing docs, and LogsConfig.
- Scoping or disabling flags. Limit evaluated flags with flag_keys and evaluation_contexts, or skip
/flagsand remote config with advanced_disable_flags (see cutting flag costs). - Batching and rate limits. Tune queue flushes and loop protection in PostHogConfig and RequestQueueConfig.





