For AI agents: a documentation index is available at /docs/llms.txt. Append .md to any page URL for markdown, or send Accept: text/markdown.
Install Amplitude on a website with a script snippet
For website owners and front-end engineers5 minBeginner
The Amplitude script snippet installs the Browser SDK on a website with no build step or npm package. Add one script to the <head> of your site when you want the fastest possible browser install. Use this option for static sites, CMS-driven sites, or any project where a script tag is easier than an SDK install.
The snippet turns on:
- Script-tag install with no bundler.
- Autocapture and Session Replay.
- Remote config for feature flags.
Prerequisites
- An Amplitude project and its API key. Create a free Amplitude account if you need one.
- Access to edit the
<head>of every page you want to track.
Install the snippet
Paste
Paste the snippet into your site's `<head>`
Add it to every page you want to track.
html<script src="https://cdn.amplitude.com/script/AMPLITUDE_API_KEY.js"></script> <script> // sampleRate: 1 records 100% of sessions for initial testing; lower this for production. The SDK default (0) records nothing. window.amplitude.add(window.sessionReplay.plugin({ sampleRate: 1 })); window.amplitude.init("AMPLITUDE_API_KEY", { fetchRemoteConfig: true, autocapture: { attribution: true, fileDownloads: true, formInteractions: true, pageViews: true, sessions: true, elementInteractions: true, networkTracking: true, webVitals: true, frustrationInteractions: true, }, }); </script>Set
Set your API key and load the page
Replace the placeholder with your project's API key, then load a tracked page in your browser.
Confirm
Confirm data in Amplitude
Open the Amplitude Debugger and check for page view, session, and interaction events.
Tips for the script snippet
- Click the API key button in the code block to insert your key before you copy the snippet.
- Use the EU CDN host if your project uses EU data residency.
- To track business-critical actions or connect activity to known users, refer to track an event and custom user identifier in the Browser SDK documentation.
Was this helpful?