Amplitude offers multiple ways to install browser SDKs, each with different product support and version control options. This guide explains the three main installation methods and helps you choose the right approach for your needs.
Amplitude provides three main ways to install browser SDKs:
| Method | Description | Version control | Best for |
|---|---|---|---|
| Unified SDK (npm) | Single npm package with all Amplitude features | Customer-managed | Teams requiring reproducible builds and strict change management |
| Unified Script (CDN) | Single script tag that loads Amplitude capabilities | Amplitude-managed | Quick setup with automatic updates and sensible defaults |
| GTM Template | Google Tag Manager template | Template version-controlled | Teams using GTM for tag management |
Different installation methods support different Amplitude products:
| Product | Unified Script (CDN) | Unified SDK (npm) | GTM Template |
|---|---|---|---|
Analytics (@amplitude/analytics-browser) |
✅ Included | ✅ Included | ✅ Included |
| Session Replay | ✅ Included | ✅ Included | ✅ Optional (checkbox) |
| Guides & Surveys | ⚠️ Separate script | ✅ Included | ✅ Optional (checkbox) |
Web Experiment (@amplitude/experiment-tag) |
✅ Included | ❌ Not included | ❌ Not supported |
Feature Experiment (@amplitude/experiment-js-client) |
❌ Not included | ✅ Included | ❌ Not supported |
The Unified SDK provides a single npm package (@amplitude/unified) giving you access to Analytics, Session Replay, Feature Experiment, and Guides & Surveys through a single API. Install it with npm or yarn, and control the version in your package.json.
Key characteristics:
Install the dependency with npm or yarn.
npm install @amplitude/unified
yarn add @amplitude/unified
Click the Key icon to insert your Amplitude API key.
You are an Amplitude installation wizard, an expert AI programming assistant that implements Amplitude Analytics, Session Replay, Experiment, and Guides and Surveys for JavaScript-based applications.
Your task is to select, install, and initialize the correct Amplitude package(s) necessary to enable Amplitude Analytics, Session Replay, Experiment, and Guides and Surveys for this application and track key interactions, all in strict accordance to the Documentation provided below.
Rules
- Do not make any code changes if this is not a JavaScript-based application
- Ensure ALL the code added ONLY runs client-side and never server-side
- Ensure amplitude is only initialized once during the lifecycle of the application
Context
Documentation
- Install the Amplitude Analytics Browser SDK with
npm install @amplitude/unified or yarn add @amplitude/unified
- Import amplitude into the root of the client application with
import * as amplitude from '@amplitude/unified';
- Initialize amplitude with
amplitude.initAll('AMPLITUDE_API_KEY', {"analytics":{"autocapture":true},"sessionReplay":{"sampleRate":1},"experiment":{"deploymentKey":"DEPLOYMENT_KEY"},"engagement":{"serverZone":"US","logLevel":LogLevel.Warn}});
The Unified SDK provides a single initialization method that initializes all Amplitude features.
import { initAll } from '@amplitude/unified';
initAll('AMPLITUDE_API_KEY');
The Unified SDK provides access to all Amplitude features through a single interface:
import {
track,
identify,
experiment,
sessionReplay
} from '@amplitude/unified';
// Track events
track('Button Clicked', { buttonName: 'Sign Up' });
// Identify users
identify(new Identify().set('userType', 'premium'));
// Access Experiment features
const variant = await experiment.fetch('experiment-key');
// Access Session Replay features
sessionReplay.flush();
The Unified SDK supports configuration options for all Amplitude features. You can configure each product individually while sharing some common options.
import { initAll } from '@amplitude/unified';
initAll('AMPLITUDE_API_KEY', {
// Shared options for all SDKs (optional)
serverZone: 'US', // or 'EU'
instanceName: 'my-instance',
// Analytics options
analytics: {
// Analytics configuration options
},
// Session Replay options
sessionReplay: {
// Session Replay configuration options
sampleRate: 1 // To enable session replay
},
// Experiment options
experiment: {
// Experiment configuration options
},
// Guides and Surveys options
engagement: {
// Guides and Surveys configuration options
}
});
| Name | Type | Default | Description |
|---|---|---|---|
serverZone |
'US' or 'EU' |
'US' |
The server zone to use for all SDKs. |
instanceName |
string |
$default_instance |
A unique name for this instance of the SDK. |
All options from @amplitude/analytics-browser are supported. Refer to the Analytics Browser SDK documentation for details.
The Unified Browser SDK supports all options from @amplitude/plugin-session-replay-browser. Refer to the Session Replay Plugin documentation for more information. Set config.sessionReplay.sampleRate to a non-zero value to enable Session Replay.
Sample rate controls the rate at which Amplitude captures session replays. For example, if you set config.sessionReplay.sampleRate to 0.5, Session Replay captures roughly half of all sessions.
All options from @amplitude/plugin-experiment-browser are supported. Refer to the Experiment documentation for details.
The Unified Browser SDK supports all Guides and Surveys options. The engagement plugin initializes automatically when you pass engagement options in the configuration.
The Unified Script is a single script tag that loads Amplitude browser capabilities from Amplitude's CDN. Amplitude remotely controls the versions of the underlying SDKs, offering a "single line of code" experience with sensible defaults and optional remote or manual configuration.
Key characteristics:
Add the following script tag to the <head> of your site:
<script src="https://cdn.amplitude.com/script/AMPLITUDE_API_KEY.js"></script>
Replace AMPLITUDE_API_KEY with your project's API key.
The Unified Script enables Session Replay and Web Experiment by default. For manual configuration:
<script src="https://cdn.amplitude.com/script/AMPLITUDE_API_KEY.js"></script>
<script>
window.amplitude.init('AMPLITUDE_API_KEY', {
defaultTracking: true,
autocapture: true,
fetchRemoteConfig: true
});
// Enable Session Replay with custom sample rate
window.amplitude.add(window.sessionReplay.plugin({ sampleRate: 1 }));
</script>
Because of size concerns, Guides & Surveys requires a separate script. Add it after the Unified Script:
<script src="https://cdn.amplitude.com/script/AMPLITUDE_API_KEY.js"></script>
<script src="https://cdn.amplitude.com/script/AMPLITUDE_API_KEY.engagement.js"></script>
<script>
window.amplitude.add(window.engagement.plugin());
window.amplitude.init('AMPLITUDE_API_KEY', {
fetchRemoteConfig: true,
autocapture: true
});
</script>
Refer to the Guides and Surveys SDK documentation for more configuration options.
The Amplitude GTM template directly wraps the Analytics Browser 2.0 SDK (@amplitude/analytics-browser). It doesn't use the Unified SDK or Unified Script.
Key characteristics:
To enable these features:
Refer to the Google Tag Manager documentation for detailed configuration options.
April 3rd, 2026
Need help? Contact Support
Visit Amplitude.com
Have a look at the Amplitude Blog
Learn more at Amplitude Academy
© 2026 Amplitude, Inc. All rights reserved. Amplitude is a registered trademark of Amplitude, Inc.