@amplitude/analytics-browser

The official Amplitude Web SDK for capturing product-analytics events, sessions, and web attribution in the browser.

SDK
npm
v2.45.8
180stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
89/100Excellent
Development Activity96
Maintenance100
Community84
Maturity56
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
85/100Excellent
Architecture85
Code Quality90
Innovation75
Learning Curve90

@amplitude/analytics-browser is Amplitude’s official TypeScript SDK for tracking product-analytics events from browser-based applications. It ships as both an npm package and a drop-in script-loader snippet, and wraps event queuing, session management, device/user identity, and network transport behind a small init()/track() API so teams can start sending events with a few lines of code.

Beyond manual event tracking, the SDK bundles a set of first-party autocapture plugins for page views, form interactions, file downloads, network requests, web vitals, and DOM “frustration” signals (rage clicks, dead clicks), plus attribution tracking for marketing campaign parameters and page-URL/custom event enrichment. These are wired in through @amplitude/analytics-core’s plugin architecture and can be toggled granularly via the autocapture config option.

The package is one piece of the larger amplitude/Amplitude-TypeScript pnpm/Nx monorepo, which also publishes @amplitude/analytics-node, @amplitude/analytics-react-native, and companion plugins like @amplitude/plugin-session-replay-browser. analytics-browser depends on several of these workspace plugins directly, so installing it pulls in a curated default tracking stack rather than a bare event pipe.

It supports remote config fetching (to adjust tracking behavior without a redeploy), configurable server zones (US/EU data residency), pluggable transports, and diagnostics sampling — features aimed at teams running Amplitude at production scale rather than a toy tracking script.

What You Get

  • Core tracking API - init, track, identify, groupIdentify, revenue, and setUserId/setDeviceId for manual event and identity instrumentation.
  • Built-in autocapture plugins - page view tracking, form interaction tracking, file download tracking, network capture, web vitals, and frustration-interaction (rage/dead click) detection enabled by default and individually configurable.
  • Web attribution tracking - automatic capture of UTM parameters, click IDs, and referrer data to tie events back to marketing campaigns.
  • Remote config support - fetches tracking configuration from Amplitude’s servers at init time so behavior can be adjusted without a client redeploy.
  • Script-loader distribution - a minified CDN snippet with a queuing shim, so pages can start tracking before the full SDK has loaded.
  • Server-zone and transport configuration - explicit US/EU server zone selection and a pluggable transport layer (fetch, XHR, beacon) for network delivery.
  • Session Replay integration point - designed to compose with @amplitude/plugin-session-replay-browser from the same monorepo for recording user sessions alongside events.

Common Use Cases

  • Product analytics instrumentation - a SaaS team adds amplitude.init() plus amplitude.track() calls to measure feature adoption and funnels.
  • Marketing attribution - a growth team relies on the built-in web-attribution plugin to connect ad-campaign UTM parameters to downstream conversion events.
  • Passive UX signal capture - a product team enables frustration-interaction tracking to surface rage clicks and dead clicks without hand-instrumenting every button.
  • Regulated data residency - an EU-based company sets serverZone: 'EU' so all analytics traffic is processed in Amplitude’s EU infrastructure.
  • Legacy-page instrumentation - a marketing site with no build step uses the CDN script-loader snippet to start tracking without an npm install.

Under The Hood

Architecture The package composes a monolithic AmplitudeBrowser client (extending AmplitudeCore from the shared @amplitude/analytics-core package) with a set of independently-published plugin packages injected as constructor-time dependencies rather than imported ad hoc. init() in browser-client.ts walks through a staged sequence — resolve logger and server zone, optionally fetch remote config via RemoteConfigClient, build a BrowserConfig, construct a Destination/transport pipeline, then conditionally register each autocapture plugin (page views, forms, file downloads, network capture, web vitals, frustration signals, attribution, enrichment) based on resolved AutocaptureOptions. Public exports in index.ts are destructured off a lazily-created singleton client via browser-client-factory.ts, and a parallel snippet-index.ts/generated/ build produces the CDN script-loader bundle with its own queuing shim. Changing the core plugin-registration contract in AmplitudeCore would ripple through every first-party plugin package in the monorepo, since they all implement the same plugin interface.

Tech Stack Written entirely in TypeScript, built with Rollup (rollup.config.js) for the browser/CDN bundle and tsc for separate ES5 and ESM output targets, inside an Nx + Lerna + pnpm-workspaces monorepo (amplitude/Amplitude-TypeScript) that also builds @amplitude/analytics-node, @amplitude/analytics-react-native, and a family of plugin-*-browser packages consumed here as workspace dependencies. Runtime dependencies are limited to tslib plus sibling workspace plugin packages — no external analytics or HTTP libraries are pulled in, keeping the shipped bundle lean.

Code Quality Testing uses Jest with jest-environment-jsdom and a shared root config extended per-package; the test/ directory mirrors src/ closely (browser-client.test.ts, config.test.ts, default-tracking.test.ts, per-plugin test folders) and coverage-path ignores are scoped narrowly to snippet/global-scope glue code, suggesting deliberate coverage tracking rather than blanket exclusion. ESLint + Prettier run via pnpm lint/fix scripts, ts-strict typing is used throughout (explicit @ts-ignore comments are annotated with reasons where used), and Playwright end-to-end tests plus a dedicated ci.yml/ci-nx.yml/e2e.yml GitHub Actions pipeline cover build, lint, unit, and browser e2e stages.

API Design The public surface is intentionally small — init, track, identify, groupIdentify, revenue, plus getter/setter pairs for device/user/session IDs — with sensible defaults so most integrations need only an API key. Autocapture is opt-out rather than opt-in (enabled by default, individually disable-able via a typed AutocaptureOptions object), which minimizes required configuration for common analytics needs while still exposing granular control for teams that want it. Backward-compatible type re-exports (export * as Types) and a documented, commented rationale in index.ts show attentiveness to not breaking downstream consumers across versions.

Used by 10 apps in this directory

Ruby
49%
Other

Chatwoot

Customer Support

36,549

Open-source omnichannel customer support platform with AI-powered agents, live chat, and self-hosting — a full Intercom and Zendesk alternative.

View details
95
Repo Health
78
Technical
69
Dependency
Built with
Ruby49%
Vue26%
JavaScript22%
Updated yesterday
JavaScript
90%
Other

CodeSandbox

Code Editors · Developer Tools

13,640

Instantly ready browser-based IDE that runs full npm dependency resolution and transpilation entirely client-side, with no server needed.

View details
69
Repo Health
76
Technical
62
Dependency
Built with
JavaScript90%
Updated 1 weeks ago
TypeScript
50%
Other

Dify

No Code Platforms · AI Development · Developer Tools

154,649

Visual LLM workflow platform with RAG pipelines, agent capabilities, and model management for building production AI applications.

View details
92
Repo Health
85
Technical
67
Dependency
Built with
TypeScript50%
Python46%
Updated yesterday
TypeScript
50%
Other

Dify

No Code Platforms · AI Development · Developer Tools

154,649

Visual LLM workflow platform with RAG pipelines, agent capabilities, and model management for building production AI applications.

View details
92
Repo Health
85
Technical
67
Dependency
Built with
TypeScript50%
Python46%
Updated yesterday
Python
63%
BSD 3

Flagsmith

Developer Tools · Devops · Ab Testing Experimentation

6,539

Open-source feature flagging, remote config, and A/B/multivariate testing platform for web, mobile, and server-side apps — self-host or use the hosted SaaS.

View details
90
Repo Health
82
Technical
63
Dependency
Built with
Python63%
TypeScript31%
Updated 2 days ago
Python
63%
BSD 3

Flagsmith

Developer Tools · Devops · Ab Testing Experimentation

6,539

Open-source feature flagging, remote config, and A/B/multivariate testing platform for web, mobile, and server-side apps — self-host or use the hosted SaaS.

View details
90
Repo Health
82
Technical
63
Dependency
Built with
Python63%
TypeScript31%
Updated 2 days ago
TypeScript
74%
Apache 2.0

Jitsi Meet

Team Chat · Collaboration · Video Conferencing

29,879

Open-source, end-to-end encrypted video conferencing you can self-host or embed into any web or mobile app.

View details
96
Repo Health
85
Technical
69
Dependency
Built with
TypeScript74%
JavaScript10%
Updated yesterday
TypeScript
74%
Apache 2.0

Jitsi Meet

Team Chat · Collaboration · Video Conferencing

29,879

Open-source, end-to-end encrypted video conferencing you can self-host or embed into any web or mobile app.

View details
96
Repo Health
85
Technical
69
Dependency
Built with
TypeScript74%
JavaScript10%
Updated yesterday
Python
54%
Other

PostHog

Analytics · Monitoring · Developer Tools

39,612

The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.

View details
92
Repo Health
80
Technical
65
Dependency
Built with
Python54%
TypeScript36%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search