### Quick Start: Initialize and Evaluate User Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/experiment-sdks/en/experiment-node-js.md A quick start guide to initialize the local evaluation client, start it, and evaluate a user. ```APIDOC ## Quick Start: Initialize and Evaluate User 1. Initialize the local evaluation client. 2. Start the local evaluation client. 3. Evaluate a user. ```js import { Experiment } from '@amplitude/experiment-node-server'; // (1) Initialize the local evaluation client with a server deployment key. const experiment = Experiment.initializeLocal('', { // (Recommended) Enable local evaluation cohort targeting. cohortSyncConfig: { apiKey: '', secretKey: '' } }); // (2) Start the local evaluation client. await experiment.start(); // (3) Evaluate a user. const user = { device_id: 'abcdefg' }; const variants = experiment.evaluateV2(user); ``` ``` -------------------------------- ### Installation and Setup Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/browser_sdk/en/ampli-for-browser-sdk-1-0.md Instructions for installing the Amplitude SDK, Ampli CLI, and pulling the Ampli Wrapper into your project. ```APIDOC ## Installation and Setup ### 1. Install the Amplitude SDK **npm:** ```bash npm install @amplitude/analytics-browser ``` **yarn:** ```bash yarn add @amplitude/analytics-browser ``` *Note: For browser usage, Amplitude recommends loading `@amplitude/analytics-browser` as a module.* ### 2. Install the Ampli CLI **Homebrew:** ```bash brew tap amplitude/ampli brew install ampli ``` **NPM:** ```bash npm install -g @amplitude/ampli ``` ### 3. Pull the Ampli Wrapper Use the Ampli CLI to pull the generated wrapper into your project. ```bash ampli pull [--path ./src/ampli] ``` ``` -------------------------------- ### Install Guides and Surveys via npm Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/guides_and_surveys/en/sdk.md Install the engagement-browser package using npm. Import the plugin and register it with the Amplitude Browser SDK. This method initializes Guides and Surveys alongside Analytics. ```bash npm install @amplitude/engagement-browser ``` ```typescript import { plugin as engagementPlugin } from '@amplitude/engagement-browser'; amplitude.add(engagementPlugin()); ``` -------------------------------- ### Local Evaluation - Quick Start Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/experiment-sdks/en/experiment-go.md A quick start guide to initializing, starting, and evaluating users with the local evaluation client. ```APIDOC ## Local Evaluation ### Description Implements evaluating variants for a user through local evaluation. If you plan on using local evaluation, you should understand the tradeoffs. ### Initialize Local Evaluation Client Initialize the local evaluation client with a server deployment key. ```go // (1) Initialize the local evaluation client with a server deployment key. client := local.Initialize("", &local.Config{ // (Recommended) Enable local evaluation cohort targeting. CohortSyncConfig: &local.CohortSyncConfig { ApiKey: "", SecretKey: "" } }) ``` ### Start Local Evaluation Client Start the local evaluation client to begin processing flag configurations. ```go // (2) Start the local evaluation client. err := client.Start() if err != nil { panic(err) } ``` ### Evaluate User Evaluate a user to get their assigned variants. ```go // (3) Evaluate a user. user := &experiment.User{DeviceId: "abcdefg"} variants, err := client.EvaluateV2(user, nil) if err != nil { panic(err) } ``` ``` -------------------------------- ### Installation and Setup Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/node_js_sdk/en/node-js-ampli-wrapper.md Instructions for installing the Amplitude SDK, Ampli CLI, and pulling the Ampli Wrapper into your Node.js project. ```APIDOC ## Installation and Setup ### Install the Amplitude SDK **npm:** ```bash npm install @amplitude/analytics-node ``` **yarn:** ```bash yarn add @amplitude/analytics-node ``` ### Install the Ampli CLI **Homebrew:** ```bash brew tap amplitude/ampli brew install ampli ``` **npm:** ```bash npm install -g @amplitude/ampli ``` ### Pull the Ampli Wrapper into your project Run the Ampli CLI `pull` command to log in to Amplitude Data and download the strongly typed Ampli Wrapper for your tracking plan. Ampli CLI commands are usually run from the project root directory. ```bash ampli pull ``` ``` -------------------------------- ### Install Guides and Surveys via Yarn Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/guides_and_surveys/en/sdk.md Install the engagement-browser package using Yarn. Import the plugin and register it with the Amplitude Browser SDK. This method initializes Guides and Surveys alongside Analytics. ```bash yarn add @amplitude/engagement-browser ``` ```typescript import { plugin as engagementPlugin } from '@amplitude/engagement-browser'; amplitude.add(engagementPlugin()); ``` -------------------------------- ### Quick Start: Initialize, Start, and Evaluate User with Node.js SDK Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/experiment-sdks/en/experiment-node-js.md Initialize the local evaluation client with a server deployment key, start the client, and then evaluate a user to get their experiment variants. Ensure you have your deployment key, API key, and secret key. ```javascript import { Experiment } from '@amplitude/experiment-node-server'; // (1) Initialize the local evaluation client with a server deployment key. const experiment = Experiment.initializeLocal('', { // (Recommended) Enable local evaluation cohort targeting. cohortSyncConfig: { apiKey: '', secretKey: '' } }); // (2) Start the local evaluation client. await experiment.start(); // (2) Evaluate a user. const user = { device_id: 'abcdefg' }; const variants = experiment.evaluateV2(user); ``` -------------------------------- ### Install Amplitude Experiment Go SDK Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/experiment-sdks/en/experiment-go.md This snippet shows how to install the Amplitude Experiment Go SDK using the go get command. Ensure you have Go installed and configured in your environment. ```bash go get github.com/amplitude/experiment-go-server ``` -------------------------------- ### Local Evaluation Client Quick Start Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/experiment-sdks/en/experiment-jvm.md A quick start guide to initializing, starting, and using the local evaluation client to evaluate users. ```APIDOC ## Local Evaluation Client Quick Start 1. Initialize the local evaluation client. 2. Start the local evaluation client. 3. Evaluate a user. ### Kotlin Example ```kotlin // (1) Initialize the local evaluation client with a server deployment key. val experiment = Experiment.initializeLocal( "", // (Recommended) Enable local evaluation cohort targeting. LocalEvaluationConfig.builder() .cohortSyncConfig(CohortSyncConfig("", "")) .build() ) // (2) Start the local evaluation client. experiment.start() // (3) Evaluate a user. val user = ExperimentUser.builder() .userId("user@company.com") .deviceId("abcdefg") .userProperty("premium", true) .build() val variants = experiment.evaluate(user) ``` ### Java Example ```java // (1) Initialize the local evaluation client with a server deployment key. LocalEvaluationClient experiment = Experiment.initializeLocal("", // (Recommended) Enable local evaluation cohort targeting. LocalEvaluationConfig.builder() .cohortSyncConfig(new CohortSyncConfig("", "")) .build()); // (2) Start the local evaluation client. experiment.start(); // (3) Evaluate a user. ExperimentUser user = ExperimentUser.builder() .userId("user@company.com") .deviceId("abcdefg") .userProperty("premium", true) .build(); Map variants = experiment.evaluate(user); ``` ``` -------------------------------- ### Initialization and Usage Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/browser_sdk/en/ampli-for-browser-sdk-1-0.md Guide on how to initialize the Ampli Wrapper and start tracking events in your application. ```APIDOC ## Initialization and Usage ### Initialize the Ampli Wrapper Import and load the Ampli wrapper with your Amplitude API key. ```javascript import { ampli } from './src/ampli'; ampli.load({ client: { apiKey: AMPLITUDE_API_KEY } }); ``` ### Identify Users and Set Properties Use the `identify` method to set user properties. ```javascript ampli.identify('user-id', { userProp: 'A trait associated with this user' }); ``` ### Track Events Track events using the strongly typed methods or by instantiating event classes. **Using strongly typed methods:** ```javascript ampli.songPlayed({ songId: 'song-1' }); ``` **Using event classes:** ```javascript import { SongPlayed } from './src/ampli'; // Assuming SongPlayed is exported ampli.track(new SongPlayed({ songId: 'song-2' })); ``` ### Flush Events Ensure all queued events are sent before the application exits. ```javascript ampli.flush(); ``` ### Verify Implementation Status Use the Ampli CLI to check the status of your implementation. ```shell ampli status [--update] ``` ``` -------------------------------- ### Install Amplitude Go SDK Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/go_sdk/en/ampli-for-go.md Installs the core Amplitude analytics library for Go using the go get command. ```shell go get github.com/amplitude/analytics-go ``` -------------------------------- ### Initialize Amplitude SDK Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/pages/en/components.md Installs the browser SDK, imports the library, and initializes it with an API key. This is the standard setup process for web applications. ```bash npm install @amplitude/analytics-browser ``` ```javascript import * as amplitude from '@amplitude/analytics-browser'; amplitude.init('YOUR_API_KEY', { defaultTracking: true }); ``` -------------------------------- ### Verify Engagement SDK Initialization Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/guides_and_surveys/en/sdk.md Check if the Guides and Surveys SDK is properly installed and initialized by inspecting the `window.engagement` object in the browser console. If it returns `undefined`, the installation failed. ```javascript window.engagement ``` -------------------------------- ### Quick Start: Initialize and Evaluate User with Java Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/experiment-sdks/en/experiment-jvm.md Initialize the local evaluation client, start it, and then evaluate a user's feature flags. Ensure you have a server deployment key. ```java // (1) Initialize the local evaluation client with a server deployment key. LocalEvaluationClient experiment = Experiment.initializeLocal("", // (Recommended) Enable local evaluation cohort targeting. LocalEvaluationConfig.builder() .cohortSyncConfig(new CohortSyncConfig("", "")) .build()); // (2) Start the local evaluation client. experiment.start(); // (3) Evaluate a user. ExperimentUser user = ExperimentUser.builder() .userId("user@company.com") .deviceId("abcdefg") .userProperty("premium", true) .build(); Map variants = experiment.evaluate(user); ``` -------------------------------- ### Example: Get Property for Specific Event Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/api/en/taxonomy.md A concrete example showing how to retrieve the 'Completed Task' property for the 'Onboard Start' event using base64 encoded credentials. ```bash curl --location --request GET 'https://amplitude.com/api/2/taxonomy/event-property?event_property=Completed Task' \ --header 'Authorization: Basic MTIzNDU2NzgwMDoxMjM0NTY3MDA=' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'event_type=Onboard Start' ``` ```http GET /api/2/taxonomy/event-property?event_property=Completed Task HTTP/1.1 Host: amplitude.com Authorization: Basic MTIzNDU2NzgwMDoxMjM0NTY3MDA== Content-Type: application/x-www-form-urlencoded Content-Length: 26 event_type=Onboard%20Start ``` -------------------------------- ### Get Specific Event Properties Example Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/api/en/taxonomy.md Demonstrates how to retrieve all properties associated with a specific event, such as 'Onboard Start'. ```bash curl --location --request GET 'https://amplitude.com/api/2/taxonomy/event-property' \ --header 'Authorization: Basic MTIzNDU2NzgwMDoxMjM0NTY3MDA==' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'event_type=Onboard Start' ``` ```http GET /api/2/taxonomy/event-property HTTP/1.1 Host: amplitude.com Authorization: Basic MTIzNDU2NzgwMDoxMjM0NTY3MDA== Content-Type: application/x-www-form-urlencoded Content-Length: 26 event_type=Onboard%20Start ``` -------------------------------- ### Experiment JVM SDK - Remote Evaluation Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/experiment-sdks/en/experiment-jvm.md This section details how to install and use the Amplitude Experiment JVM SDK for remote evaluation. It includes installation instructions, quick start guides, and initialization procedures for both Kotlin and Java. ```APIDOC ## Install JVM Server SDK Install the JVM Server SDK using Gradle. ### Method ```groovy implementation "com.amplitude:experiment-jvm-server:" ``` ```kotlin implementation("com.amplitude:experiment-jvm-server:") ``` ## Quick Start - Remote Evaluation 1. Initialize the experiment client. 2. Fetch variants for the user. 3. Access a flag's variant. ### Kotlin Example ```kotlin // (1) Initialize the remote evaluation client with a server deployment key. val experiment = Experiment.initializeRemote("") // (2) Fetch variants for a user val user = ExperimentUser.builder() .userId("user@company.com") .deviceId("abcdefg") .userProperty("premium", true) .build() val variants = try { experiment.fetch(user).get() } catch (e: Exception) { e.printStackTrace() return } // (3) Access a flag's variant val variant = variants[""] if (variant?.value == "on") { // Flag is on } else { // Flag is off } ``` ### Java Example ```java // (1) Initialize the remote evaluation client with a server deployment key. RemoteEvaluationClient experiment = Experiment.initializeRemote(""); // (2) Fetch variants for a user ExperimentUser user = ExperimentUser.builder() .userId("user@company.com") .deviceId("abcdefg") .userProperty("premium", true) .build(); Map variants; try { variants = experiment.fetch(user).get(); } catch (Exception e) { e.printStackTrace(); return; } // (3) Access a flag's variant Variant variant = variants.get(""); if (Variant.valueEquals(variant, "on")) { // Flag is on } else { // Flag is off } ``` ## Initialize Remote Evaluation Client The SDK client should be initialized in your server on startup. The `apiKey` parameter passed into the `apiKey` argument must live within the same project that you are sending analytics events to. ### Kotlin ```kotlin fun initializeRemote( apiKey: String, config: RemoteEvaluationConfig = RemoteEvaluationConfig() ): RemoteEvaluationClient ``` **Parameters**: - **apiKey** (string) - required - The [deployment key](/docs/feature-experiment/data-model#deployments) which authorizes fetch requests and determines which flags should be evaluated for the user. - **config** (RemoteEvaluationConfig) - optional - The client [configuration](#configuration) used to customize SDK client behavior. **Example**: ```kotlin val experiment = Experiment.initializeRemote("") ``` ### Java ```java @Nonnull public RemoteEvaluationClient initializeRemote( @Nonnull String apiKey, @Nonnull RemoteEvaluationConfig config ); ``` **Parameters**: - **apiKey** (string) - required - The [deployment key](/docs/feature-experiment/data-model#deployments) which authorizes fetch requests and determines which flags should be evaluated for the user. - **config** (RemoteEvaluationConfig) - required - The client [configuration](#configuration) used to customize SDK client behavior. **Example**: ```java RemoteEvaluationClient experiment = Experiment.initializeRemote(""); ``` ``` -------------------------------- ### Enrichment Type Plugin Example for Amplitude SDK Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/react_native_sdk/en/react-native-sdk.md Provides an example of an enrichment type plugin for the Amplitude SDK. This plugin, `AddEventIdPlugin`, modifies each event by adding an incrementing `event_id` starting from 100. It includes implementations for `setup` and `execute` methods. ```typescript import { init, add } from '@amplitude/analytics-react-native'; import { ReactNativeConfig, EnrichmentPlugin, Event, PluginType } from '@amplitude/analytics-types'; export class AddEventIdPlugin implements EnrichmentPlugin { name = 'add-event-id'; type = PluginType.ENRICHMENT as const; currentId = 100; config?: ReactNativeConfig; /** * setup() is called on plugin installation * example: client.add(new AddEventIdPlugin()); */ async setup(config: ReactNativeConfig): Promise { this.config = config; return; } /** * execute() is called on each event instrumented * example: client.track('New Event'); */ async execute(event: Event): Promise { event.event_id = this.currentId++; return event; } } init('API_KEY'); add(new AddEventIdPlugin()); ``` -------------------------------- ### Quick Start: Initialize and Evaluate User with Kotlin Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/experiment-sdks/en/experiment-jvm.md Initialize the local evaluation client, start it, and then evaluate a user's feature flags. Ensure you have a server deployment key. ```kotlin // (1) Initialize the local evaluation client with a server deployment key. val experiment = Experiment.initializeLocal( "", // (Recommended) Enable local evaluation cohort targeting. LocalEvaluationConfig.builder() .cohortSyncConfig(CohortSyncConfig("", "")) .build() ) // (2) Start the local evaluation client. experiment.start() // (3) Evaluate a user. val user = ExperimentUser.builder() .userId("user@company.com") .deviceId("abcdefg") .userProperty("premium", true) .build() val variants = experiment.evaluate(user) ``` -------------------------------- ### Export Translations using curl (Single Key/Locale) Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/guides_and_surveys_api/en/guides-and-surveys-api-localization.md Example using curl to GET translations for a specific guide or survey key and locale. Ensure the Authorization header is correctly formatted with your Base64 encoded credentials. ```bash curl -X GET \ -H "Authorization: Basic YOUR_BASE64_ENCODED_CREDENTIALS" \ "https://app.amplitude.com/a/guides-surveys/api/v1/localization/export/?key=nudge-translated-announcement-1&locale=de" ``` -------------------------------- ### Get Monthly N-Day Retention (cURL/HTTP) Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/api/en/dashboard-rest.md This example demonstrates fetching monthly N-day retention data. The `i=30` parameter indicates monthly intervals, and the `start` and `end` parameters define the data period. Basic authentication is required. ```cURL curl --location -g --request GET 'http://amplitude.com/api/2/retention?se={"event_type":"_active"}&re={"event_type":"watch_tutorial"}&start=20210726&end=20210905&i=30' --header 'Authorization: Basic MTIzNDU2NzgwMDoxMjM0NTY3MDA=' ``` ```HTTP GET /api/2/retention?se={"event_type":"_active"}&re={"event_type":"watch_tutorial"}&start=20210726&end=20210905&i=30 HTTP/1.1 Host: amplitude.com Authorization: Basic MTIzNDU2NzgwMDoxMjM0NTY3MDA= ``` -------------------------------- ### Initialize Amplitude SDK Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/unity_sdk/en/unity-sdk.md Demonstrates how to obtain an Amplitude instance, configure the server URL, enable logging, and initialize the SDK with an API key. ```c# Amplitude amplitude = Amplitude.getInstance(); amplitude.setServerUrl("https://api2.amplitude.com"); amplitude.logging = true; amplitude.trackSessionEvents(true); amplitude.init(AMPLITUDE_API_KEY); ``` -------------------------------- ### Installation Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/python_sdk/en/ampli-for-python-sdk.md Instructions for installing the Amplitude SDK and the Ampli CLI. ```APIDOC ## Installation ### Install the Amplitude SDK If you haven't already, install the core Amplitude SDK dependencies. ```bash pip install amplitude-analytics ``` ### Install Ampli CLI You can install the [Ampli CLI](/docs/sdks/ampli/ampli-cli) from Homebrew or NPM. #### npm ```bash npm install -g @amplitude/ampli ``` #### brew ```bash brew tap amplitude/ampli brew install ampli ``` ``` -------------------------------- ### Start Development Server Source: https://github.com/amplitude/amplitude-docs/blob/main/README.md Builds the necessary CSS and JavaScript assets and starts the development server. This command should be run from the repository's root directory. ```bash npm run dev ``` -------------------------------- ### Tool Definition: GET Request Example Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/assistant/en/configure-assistant.md Example of defining a GET request for a custom tool in AI Assistant. This demonstrates how to specify the HTTP method, endpoint with a URL parameter, and the parameter details. ```json { "Method": "GET", "Endpoint": "https://weather.example.com/search?city={{city}}", "Parameters": { "city": { "Type": "string", "Required": true, "Description": "The city to look up the weather for." } }, "Body": "" } ``` -------------------------------- ### Example: Get active users for a period (HTTP) Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/api/en/dashboard-rest.md Example HTTP request to get active users within a date range, counted daily. Authentication is provided via the Authorization header. ```http GET /api/2/users?start=20210101&end=20210901&m=active HTTP/1.1 Host: amplitude.com Authorization: Basic MTIzNDU2NzgwMDoxMjM0NTY3MDA= ``` -------------------------------- ### Initialize Remote Evaluation Client Example Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/experiment-sdks/en/experiment-jvm.md Example of initializing the remote evaluation client with a deployment key. Replace `` with your actual key. ```kotlin val experiment = Experiment.initializeRemote("") ``` ```java RemoteEvaluationClient experiment = Experiment.initializeRemote(""); ``` -------------------------------- ### Initialize Experiment SDK Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/experiment-sdks/en/experiment-react-native.md Call `start()` when your application initializes to fetch flag configurations and remote evaluation variants. The SDK is ready once the returned promise resolves. Use `fetchOnStart: false` to avoid startup latency if remote evaluation is not needed immediately. ```javascript await experiment.start(); ``` ```javascript const user = { user_id: 'user@company.com', device_id: 'abcdefg', user_properties: { premium: true } }; await experiment.start(user); ``` -------------------------------- ### Install Amplitude SDK with Browser Snippet Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/get-started/en/amplitude-quickstart.md Paste this script tag into the `` of your website for a quick setup. No build step or codebase access is required. Ensure your Amplitude API key is inserted. ```html ``` -------------------------------- ### Install SDK with Yarn Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/guides_and_surveys/en/guides-and-surveys-rn-sdk.md Install the Guides and Surveys React Native SDK and its dependency using Yarn. ```bash yarn add @amplitude/plugin-engagement-react-native yarn add @react-native-async-storage/async-storage ``` -------------------------------- ### Install SDK with npm Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/guides_and_surveys/en/guides-and-surveys-rn-sdk.md Install the Guides and Surveys React Native SDK and its dependency using npm. ```bash npm install @amplitude/plugin-engagement-react-native npm install @react-native-async-storage/async-storage ``` -------------------------------- ### Boot Method Initialization Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/guides_and_surveys/en/sdk.md The `boot` method initializes the Guides and Surveys SDK. It's crucial for enabling targeting resolution and connecting to your analytics provider. Call this method once per session, providing user information and integration details. ```APIDOC ## POST /engagement/boot ### Description Initializes the Amplitude Guides and Surveys SDK, enabling targeting resolution for live guides and surveys and establishing a connection to your analytics provider. This method must be called once per session unless the active user needs to be changed. ### Method POST ### Endpoint `/engagement/boot` ### Parameters #### Request Body - **options** (object) - Required - Configuration options for booting the SDK. - **options.user** (EndUser | (() => EndUser) | string) - Required - User information. Can be an `EndUser` object, a function returning an `EndUser` object, or a user ID string. Must contain at least `user_id` or `device_id`. - **options.integrations** (Array) - Required - An array of integrations for tracking events. Essential for sending Guides and Surveys events to your analytics provider. - **options.autoRefreshIntervalSeconds** (number) - Deprecated. Use `autoRefreshIntervalSeconds` in `InitOptions` instead. Auto-refresh interval in seconds. Must be 60 or greater. If not specified, 0, or negative, auto-refresh is disabled. #### EndUser Type - **user_id** (string) - User identifier. - **device_id** (string) - Device identifier. - **user_properties** (UserProperties) - Custom user properties. - **country** (string) - Country location data. - **region** (string) - Region location data. - **platform** (string) - Platform identifier. **Note:** At least `user_id` or `device_id` must be provided in the `user` object. #### Integration Type - **track** ((event: Event) => void) - Optional. Function to track events to your analytics provider. ### Request Example ```json { "options": { "user": { "user_id": "user123", "user_properties": { "name": "John Doe", "plan": "premium", "signupDate": "2023-01-15" } }, "integrations": [ { "track": "(event) => { amplitude.track(event.event_type, event.event_properties); }" } ] } } ``` ### Response #### Success Response (200) - **void** - The method returns a Promise that resolves when the SDK is successfully booted. #### Response Example (No specific response body for success, Promise resolves) ### Error Handling - If `user_id` or `device_id` is not provided in the `user` object, an error is logged, and the method returns early. ``` -------------------------------- ### Run Amplitude Setup Wizard CLI Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/get-started/en/setup-wizard-cli.md Execute the Amplitude Setup Wizard from your terminal to begin the automated setup process. Ensure Node.js 20+ is installed. ```shell npx @amplitude/wizard ``` -------------------------------- ### Example: Get active users segmented by city (HTTP) Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/api/en/dashboard-rest.md Example HTTP request to get active users within a date range, segmented by city and counted monthly. Authentication is handled via the Authorization header. ```http GET /api/2/users?start=20210101&end=20210901&m=active&i=30&s=[{"prop":"city","op": "is","values": ["Amsterdam"]}] HTTP/1.1 Host: amplitude.com Authorization: Basic MTIzNDU2NzgwMDoxMjM0NTY3MDA= ``` -------------------------------- ### Start SDK Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/experiment-sdks/en/experiment-javascript.md Initializes the Amplitude Experiment SDK by fetching flag configurations and variants from the server. The SDK is ready once the returned promise resolves. Use `start` for client-side local evaluation. ```APIDOC ## POST /start ### Description Starts the SDK by getting flag configurations from the server and fetching remote evaluation variants for the user. The SDK is ready once the returned promise resolves. ### Method POST ### Endpoint /start ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **user** (ExperimentUser) - optional - Explicit user information to pass with the request to fetch variants. This user information is merged with user information provided from integrations via the user provider, preferring properties passed explicitly to `fetch()` over provided properties. Also sets the user in the SDK for reuse. ### Request Example ```json { "user": { "user_id": "user@company.com", "device_id": "abcdefg", "user_properties": { "premium": true } } } ``` ### Response #### Success Response (200) - **Promise** - Resolves when the SDK is ready. #### Response Example ```json // Promise resolves, no specific JSON response body for success. ``` ``` -------------------------------- ### Start SDK Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/experiment-sdks/en/experiment-react-native.md Initializes the Experiment SDK to fetch flag configurations and variants. Use `start` for client-side local evaluation and `fetch` for remote evaluation. ```APIDOC ## POST /api/start ### Description Starts the Experiment SDK to fetch flag configurations from the server and retrieve remote evaluation variants for the user. The SDK is ready once the returned promise resolves. ### Method POST ### Endpoint /api/start ### Parameters #### Request Body - **user** (ExperimentUser) - Optional - Explicit user information to pass with the request to fetch variants. This user information merges with user information from any integrations through the user provider, and prefers properties passed explicitly to `fetch()` over provided properties. Also sets the user in the SDK for reuse. ### Request Example ```json { "user": { "user_id": "user@company.com", "device_id": "abcdefg", "user_properties": { "premium": true } } } ``` ### Response #### Success Response (200) - **void** - The promise resolves when the SDK is ready. #### Response Example (Promise resolves) ``` -------------------------------- ### Example: Get Computation for Specific User Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/api/en/user-profile.md A concrete example showing how to retrieve computation 't14bqib' for user '12345'. ```bash curl --location --request GET 'https://profile-api.amplitude.com/v1/userprofile?user_id=12345&get_computations=true&comp_id=t14bqib' --header 'Authorization: Api-Key 123456789' ``` ```http GET /v1/userprofile?get_computations=true&user_id=1234&comp_id=t14bqib HTTP/1.1 Host: profile-api.amplitude.com Authorization: Api-Key 123456789 ``` -------------------------------- ### Initialize and Use Ampli Wrapper Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/browser_sdk/en/ampli-for-javascript-sdk.md Demonstrates how to load the Ampli client, identify users, track events using strongly typed methods, and flush events. ```javascript import { ampli } from './src/ampli'; ampli.load({ client: { apiKey: AMPLITUDE_API_KEY } }); ampli.identify('user-id', { userProp: 'A trait associated with this user' }); ampli.songPlayed({ songId: 'song-1' }); ampli.track(new SongPlayed({ songId: 'song-2' })); ampli.flush(); ``` -------------------------------- ### Check Guides and Surveys Installation Status Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/guides_and_surveys/en/sdk.md Use the browser's developer console to check the status of Guides and Surveys installation. Verify the presence and values of key properties like 'user', 'apiKey', 'stateInitialized', 'decideSuccessful', and 'num_guides_surveys'. ```javascript window.engagement ``` ```javascript window.engagement._.user ``` ```javascript window.engagement._debugStatus() ``` -------------------------------- ### Install Amplitude MCP Marketplace Plugin Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/agents/en/amplitude-mcp.md Add the Amplitude marketplace to your plugins and then install the Amplitude plugin. This is a one-time setup. ```bash # Add the Amplitude marketplace (one-time) /plugin marketplace add amplitude/mcp-marketplace # Install the plugin /plugin install amplitude@amplitude ``` -------------------------------- ### Implement SDK Initialization in Flutter Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/experiment-sdks/en/experiment-flutter.md Full implementation examples for initializing the SDK. Includes setup for Amplitude analytics integration and a custom third-party tracking provider configuration. ```dart import 'package:amplitude_flutter/amplitude.dart'; import 'package:amplitude_flutter/configuration.dart'; import 'package:amplitude_experiment/amplitude_experiment.dart'; final amplitude = Amplitude(Configuration(apiKey: 'API_KEY')); await amplitude.isBuilt; final experiment = await Experiment.initializeWithAmplitude( 'DEPLOYMENT_KEY', ExperimentConfig(), ); ``` ```dart import 'package:amplitude_experiment/amplitude_experiment.dart'; final experiment = await Experiment.initialize( 'DEPLOYMENT_KEY', ExperimentConfig( trackingProvider: MyExposureTracker(), ), ); ``` -------------------------------- ### Initialize SDK with start Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/experiment-sdks/en/experiment-javascript.md Call `start()` during application initialization to fetch flag configurations and remote evaluation variants. The SDK is ready once the returned promise resolves. Use `start` for client-side local evaluation. ```typescript start(user?: ExperimentUser): Promise ``` ```typescript await experiment.start(); ``` ```typescript const user = { user_id: 'user@company.com', device_id: 'abcdefg', user_properties: { premium: true } }; await experiment.start(user); ``` -------------------------------- ### Complete Amplitude SDK Integration Example in Objective-C Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/instrumentation/en/sdk-quickstart.md A comprehensive Objective-C code example demonstrating the initialization and event tracking functionalities of the Amplitude SDK. ```objectivec @import AmplitudeSwift; AMPConfiguration* configuration = [AMPConfiguration initWithApiKey:@"YOUR-API-KEY"]; Amplitude* amplitude = [Amplitude initWithConfiguration:configuration]; [amplitude track:@"Button Clicked" eventProperties:@{ @"my event prop key": @"my event prop value" }]; ``` -------------------------------- ### Get Help for Amplitude Setup Wizard CLI Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/get-started/en/setup-wizard-cli.md View available subcommands and options for the Amplitude Setup Wizard by running the --help flag. ```shell npx @amplitude/wizard --help ``` -------------------------------- ### AI Prompt for Unified SDK Installation Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/browser_sdk/en/browser-unified-sdk.md This prompt can be used with AI tools to guide the installation and initialization of Amplitude Analytics and Session Replay for JavaScript applications. ```plaintext You are an Amplitude Analytics installation wizard, an expert AI programming assistant that implements Amplitude Analytics and Session Replay for JavaScript-based applications. Your task is to select, install, and initialize the correct Amplitude package(s) necessary to enable Amplitude Analytics and Session Replay 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 1. Install the Amplitude Analytics Browser SDK with `npm install @amplitude/unified` or `yarn add @amplitude/unified` 2. Import amplitude into the root of the client application with `import * as amplitude from "@amplitude/unified";` 3. Initialize amplitude with `amplitude.initAll('AMPLITUDE_API_KEY', {"analytics":{"autocapture":true},"sessionReplay":{"sampleRate":1}});` 4. Once the events have been implemented in code, tell the user to start the application and fire an event to verify it is being sent to Amplitude. You can check the Amplitude dashboard or setup page to confirm the event was received. 5. After verifying events are working correctly, tell the user to ship their code to production. ``` -------------------------------- ### Install the SDK Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/unreal_sdk/en/unreal-sdk.md Instructions on how to install the Amplitude Unreal SDK by downloading the zip file and placing it in the project's Plugins directory. ```APIDOC ## Install the SDK Install the Unreal Engine SDK by downloading the latest version of `AmplitudeUnreal.zip` found on the [GitHub releases](https://github.com/amplitude/Amplitude-Unreal/releases/latest) page. Unzip it into a folder inside your Unreal project's `Plugins` directory. ```bash mkdir -p Plugins/AmplitudeUnreal unzip AmplitudeUnreal.zip -d Plugins/AmplitudeUnreal ``` ### Enable the SDK plugin in the editor Open your project in the UE4 editor. Navigate to **Settings > Plugins > Project > Analytics** and make sure to enable `AmplitudeUnreal`. ### Enable Amplitude as the analytics provider Navigate to **Settings -> Project Settings -> Analytics -> Amplitude** and fill in the fields with your API key. ### Include the required analytics modules In any file that involves instrumentation, you should include the necessary Unreal Engine analytics headers. ```cpp #include "Runtime/Analytics/Analytics/Public/Analytics.h" #include "Runtime/Analytics/Analytics/Public/Interfaces/IAnalyticsProvider.h" ``` ``` -------------------------------- ### Example: Get User Composition by Platform (HTTP) Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/api/en/dashboard-rest.md Example HTTP request to retrieve user composition by platform between June 1 and June 30, 2021. ```http GET /api/2/composition?start=20210601&end=20210630&p=platform HTTP/1.1 Host: amplitude.com Authorization: Basic MTIzNDU2NzgwMDoxMjM0NTY3MDA= ``` -------------------------------- ### Basic Usage Source: https://github.com/amplitude/amplitude-docs/blob/main/content/collections/node_js_sdk/en/node-js-ampli-wrapper.md Examples of initializing the Ampli Wrapper, identifying users, setting user properties, tracking events, and flushing events. ```APIDOC ## Basic Usage ### Initialize the Ampli Wrapper ```javascript import { ampli } from './src/ampli'; ampli.load({ client: { apiKey: AMPLITUDE_API_KEY } }); ``` ### Identify users and set user properties ```javascript ampli.identify('user-id', { userProp: 'A trait associated with this user' }); ``` ### Track events **Using strongly typed methods:** ```javascript ampli.songPlayed('ampli-user-id', { songId: 'song-1' }); ``` **Using the generic track method with event classes:** ```javascript ampli.track('ampli-user-id', new SongPlayed({ songId: 'song-2' })); ``` ### Flush events before application exit ```javascript ampli.flush(); ``` ### Verify implementation status with CLI ```shell ampli status [--update] ``` ```