JavaScript tag

The JavaScript tag is a lightweight JS snippet that captures frontend errors, session replays, web vitals, console logs, website analytics, memory metrics, and custom events from your browser application. All features are remotely configurable from the Better Stack UI — install the snippet once and never redeploy to change what's collected.

Prerequisites

  • A Better Stack account.
  • An application created under Error TrackingApplications.

Quick start

  1. Open your application's Frontend tab.
  2. Copy the <script> tag and place it before </head> in your HTML. See Installation for the full snippet and options.
  3. Deploy your application.
  4. Check the Verify data collection section in the Frontend tab, or open Live tail to confirm events are arriving.

That's it — errors, web vitals, analytics, and session replays are collected by default with no additional code.

What's collected by default

All collection features are enabled out of the box. Each can be toggled individually from the Frontend tab. See Configuration for details.

Feature Description
Collect frontend errors Unhandled exceptions and promise rejections.
Record web vitals Core Web Vitals (LCP, FID, CLS) and other performance metrics.
Collect console.logs console.log, console.warn, and console.error output.
Record JS heap memory JavaScript heap memory usage (Chrome only).
Record website analytics Page views, page leaves, and navigation events.
Auto-capture anonymous user events Clicks, form submissions, and rage clicks for anonymous visitors.
Record session replays DOM changes replayed visually.
Auto-capture identified user events Interactions for users identified with betterstack('user', ...).
Collect browser fingerprint Browser fingerprint for cross-session user identification.

Next steps

  • Installation — snippet, init options, identifying users, tracking custom events
  • Configuration — UI settings: collection toggles, sampling, session replays, sessions, batching, and more
  • Events reference — full schema of all captured events