# Amplitude — full agent reference This is the deep reference for AI agents instrumenting an app with Amplitude — every platform's exact install and init code, how to verify events are flowing, and how to work with Amplitude afterward via MCP. For a brief orientation, see [https://amplitude.com/llms.txt](https://amplitude.com/llms.txt). ## 1. JavaScript/web Three ways to install, in order of recommendation for an AI agent doing the work directly. ### 1.1 AI Prompt (recommended when you're delegating implementation to another AI tool) ```text Install and configure Amplitude for this JavaScript web application. Use API key: AMPLITUDE_API_KEY Requirements: - Run the implementation only on the client. - Initialize Amplitude once during app load. - Install the correct browser package for this project. - Enable fetchRemoteConfig: true. - Enable autocapture for attribution, page views, sessions, element interactions, form interactions, and file downloads. - Enable Session Replay with sampleRate: 1. - Preserve the project's existing TypeScript and framework patterns. ``` ### 1.2 npm / yarn (@amplitude/unified) ```bash npm install @amplitude/unified # or yarn add @amplitude/unified ``` ```javascript import { initAll } from "@amplitude/unified"; initAll("AMPLITUDE_API_KEY"); ``` ```javascript import { track } from "@amplitude/unified"; track("Button Clicked", { buttonId: "signup" }); ``` For the exact autocapture / Session Replay option shapes on `initAll`, see [https://amplitude.com/docs/sdks/analytics/browser/browser-unified-sdk](https://amplitude.com/docs/sdks/analytics/browser/browser-unified-sdk). ### 1.3 Snippet (no build step) Paste into the `` of every page you want to track. This is the one method that shows the full autocapture and Session Replay config explicitly, rather than behind `initAll`'s defaults: ```html ``` Use the EU CDN host (`cdn.eu.amplitude.com`) for EU data residency projects. ### 1.4 Verify events arrive Open the [Amplitude Debugger](https://amplitude.com/docs/analytics/debug-analytics) and confirm page view, session, and interaction events are reaching the project. There's no CLI verify step — the Debugger is the source of truth. ## 2. Other platforms Each platform below: install, initialize, track one event. All link to the full SDK docs for configuration beyond the basics (custom autocapture options, identity resolution, etc). ### iOS (Swift) ```text # Swift Package Manager — Xcode: File > Add Package Dependencies https://github.com/amplitude/Amplitude-Swift # CocoaPods — Podfile pod 'AmplitudeSwift', '~> 1.0' ``` ```swift import AmplitudeSwift let amplitude = Amplitude(configuration: Configuration( apiKey: "AMPLITUDE_API_KEY" )) amplitude.track(eventType: "Button Clicked") ``` Full guide: [https://amplitude.com/docs/sdks/analytics/ios/ios-swift-sdk](https://amplitude.com/docs/sdks/analytics/ios/ios-swift-sdk) ### Android (Kotlin) ```gradle dependencies { implementation 'com.amplitude:analytics-android:1.+' } ``` ```kotlin import com.amplitude.android.Amplitude val amplitude = Amplitude(AMPLITUDE_API_KEY, applicationContext) amplitude.track("Button Clicked") ``` Full guide: [https://amplitude.com/docs/sdks/analytics/android/android-kotlin-sdk](https://amplitude.com/docs/sdks/analytics/android/android-kotlin-sdk) ### Node.js ```bash npm install @amplitude/analytics-node ``` ```javascript import { init, track } from "@amplitude/analytics-node"; init("AMPLITUDE_API_KEY"); track("Button Clicked", undefined, { user_id: "user@example.com" }); ``` Full guide: [https://amplitude.com/docs/sdks/analytics/node/node-js-sdk](https://amplitude.com/docs/sdks/analytics/node/node-js-sdk) ### React Native ```bash npm install @amplitude/analytics-react-native npm install @react-native-async-storage/async-storage ``` ```javascript import { init, track } from "@amplitude/analytics-react-native"; init("AMPLITUDE_API_KEY"); track("Button Clicked"); ``` Full guide: [https://amplitude.com/docs/sdks/analytics/react-native/react-native-sdk](https://amplitude.com/docs/sdks/analytics/react-native/react-native-sdk) ### Python ```bash pip install amplitude-analytics ``` ```python from amplitude import Amplitude, BaseEvent amplitude = Amplitude("AMPLITUDE_API_KEY") amplitude.track(BaseEvent( event_type="Button Clicked", user_id="user@example.com" )) ``` Full guide: [https://amplitude.com/docs/sdks/analytics/python/python-sdk](https://amplitude.com/docs/sdks/analytics/python/python-sdk) ### Flutter ```bash flutter pub add amplitude_flutter ``` ```dart import 'package:amplitude_flutter/amplitude.dart'; import 'package:amplitude_flutter/configuration.dart'; final Amplitude amplitude = Amplitude(Configuration( apiKey: 'AMPLITUDE_API_KEY', )); await amplitude.isBuilt; amplitude.track(BaseEvent('Button Clicked')); ``` Full guide: [https://amplitude.com/docs/sdks/analytics/flutter/flutter-sdk-4](https://amplitude.com/docs/sdks/analytics/flutter/flutter-sdk-4) ### HTTP API (no SDK) Works from any environment that can make HTTP requests: ```bash curl -X POST https://api2.amplitude.com/2/httpapi \ -H "Content-Type: application/json" \ -d '{ "api_key": "AMPLITUDE_API_KEY", "events": [{ "user_id": "user@example.com", "event_type": "Button Clicked" }] }' ``` Use `https://api.eu.amplitude.com/2/httpapi` for EU data residency. Quickstart: [https://amplitude.com/docs/apis/analytics/http-api-quickstart](https://amplitude.com/docs/apis/analytics/http-api-quickstart) · Full reference: [https://amplitude.com/docs/apis/analytics/http-v2](https://amplitude.com/docs/apis/analytics/http-v2) ## 3. Working with Amplitude via AI tools, after setup - **Amplitude MCP server** — query analytics data (charts, dashboards, experiments, cohorts, taxonomy) from Claude, Cursor, or any MCP-compatible client without leaving your workflow. Endpoint: [https://mcp.amplitude.com/mcp](https://mcp.amplitude.com/mcp) (OAuth 2.0). Docs: [https://amplitude.com/docs/amplitude-ai/amplitude-mcp](https://amplitude.com/docs/amplitude-ai/amplitude-mcp). A public, read-only, no-auth docs MCP server is also available at [https://amplitude.com/docs/api/mcp](https://amplitude.com/docs/api/mcp). Call the server's own `initialize`/`tools/list` for the current tool surface rather than relying on a static list here. - **Claude Code plugin** — built-in slash commands for charts, dashboards, and instrumentation work: [https://github.com/amplitude/mcp-marketplace/tree/main/plugins/amplitude](https://github.com/amplitude/mcp-marketplace/tree/main/plugins/amplitude) - **Custom events** — track the product events that matter once Autocapture covers the basics: [https://amplitude.com/docs/sdks/analytics/browser/browser-sdk-2#track-an-event](https://amplitude.com/docs/sdks/analytics/browser/browser-sdk-2#track-an-event) - **User identification** — connect anonymous activity to known users: [https://amplitude.com/docs/sdks/analytics/browser/browser-sdk-2#custom-user-identifier](https://amplitude.com/docs/sdks/analytics/browser/browser-sdk-2#custom-user-identifier) - **Group analytics** — analyze behavior at the account/workspace/team level: [https://amplitude.com/docs/sdks/analytics/browser/browser-sdk-2#user-groups](https://amplitude.com/docs/sdks/analytics/browser/browser-sdk-2#user-groups) - **Session Replay** — watch real user sessions alongside event data: [https://amplitude.com/docs/session-replay](https://amplitude.com/docs/session-replay) ## 4. Links - Quickstart (all platforms): [https://amplitude.com/docs/get-started/amplitude-quickstart](https://amplitude.com/docs/get-started/amplitude-quickstart) - All SDKs: [https://amplitude.com/docs/sdks](https://amplitude.com/docs/sdks) - Curated site index (every public page on amplitude.com): [https://amplitude.com/sitemap-llms.txt](https://amplitude.com/sitemap-llms.txt) - Create a free account: [https://app.amplitude.com/signup](https://app.amplitude.com/signup)