SDK Quickstart

Browser

The Browser SDK sends events to Amplitude. For more information, see the Browser SDK 2 documentation for more configuration options and advanced topics.

Install the dependency

This package is also distributed through a CDN. Copy and paste this script in your HTML file. For the latest script loader, visit Amplitude's GitHub repository.

npm install @amplitude/analytics-browser

Import Amplitude into your project:

import * as amplitude from '@amplitude/analytics-browser';
yarn add @amplitude/analytics-browser

Import Amplitude into your project:

import * as amplitude from '@amplitude/analytics-browser';

Install the dependency using NPM, YARN, or script loader.

Initialize the SDK

Before you instrument,initialize the SDK using the API Key for your Amplitude project.

amplitude.init(AMPLITUDE_API_KEY);

Send data

Next, send data from your app or website to Amplitude.

const eventProperties = {
buttonColor: 'primary',
};
amplitude.track('Button Clicked', eventProperties);

Check for success

After you begin sending data to Amplitude, use one of the debugging tools to check your instrumentation and validate your events.

Complete code example

Here's a complete example of how to use the SDK in your own app.

amplitude.init(AMPLITUDE_API_KEY, 'user@amplitude.com');
const eventProperties = {
buttonColor: 'primary',
};
 
const identifyObj = new Identify();
identifyObj.set('location', 'LAX');
amplitude.identify(identifyObj);
 
amplitude.track('Button Clicked', eventProperties);

For more information, see Browser SDK 2.

Enforce event schemas (Ampli)

The Ampli CLI, Ampli Wrapper, and Amplitude SDK work together to generate a tracking library based on your Tracking Plan. The autogenerated library provides type safety, supports linting, and enable features like input validation which contextualizes your analytics instrumentation, and reduces instrumentation mistakes.

For more information, see Ampli for Browser SDK 2.0 or examples on GitHub for:

import { ampli } from './ampli';
ampli.load({ client: { apiKey: AMPLITUDE_API_KEY } });
 
ampli.buttonClicked({
buttonColor: 'primary',
});

Node

The Node SDK sends events to Amplitude. For more information, see the Node SDK documentation for more configuration options and advanced topics.

Install the dependency

npm install @amplitude/analytics-node
yarn add @amplitude/analytics-node

Install the dependency with npm or yarn.

Initialize the SDK

Before you instrument,initialize the SDK using the API Key for your Amplitude project.

import { init } from '@amplitude/analytics-node';
 
init(AMPLITUDE_API_KEY);
import { init } from '@amplitude/analytics-node';
 
init(AMPLITUDE_API_KEY);

Send data

Next, send data from your app or website to Amplitude.

import { track } from '@amplitude/analytics-node';
 
const eventProperties = {
buttonColor: 'primary',
};
 
track('Button Clicked', eventProperties, {
user_id: 'user@amplitude.com',
});
import { track } from '@amplitude/analytics-node';
 
const eventProperties = {
buttonColor: 'primary',
};
 
track('Button Clicked', eventProperties, {
user_id: 'user@amplitude.com',
});

Check for success

After you begin sending data to Amplitude, use one of the debugging tools to check your instrumentation and validate your events.

Complete code example

Here's a complete example of how to use the SDK in your own app.

import { init, identify, Identify, track } from '@amplitude/analytics-node';
init(AMPLITUDE_API_KEY);
 
const identifyObj = new Identify();
identify(identifyObj, {
user_id: 'user@amplitude.com',
});
 
const eventProperties = {
buttonColor: 'primary',
};
track('Button Clicked', eventProperties, {
user_id: 'user@amplitude.com',
});
import { init, identify, Identify, track } from '@amplitude/analytics-node';
init(AMPLITUDE_API_KEY);
 
const identifyObj = new Identify();
identify(identifyObj, {
user_id: 'user@amplitude.com',
});
 
const eventProperties = {
buttonColor: 'primary',
};
track('Button Clicked', eventProperties, {
user_id: 'user@amplitude.com',
});

For more information, see Node SDK.

Enforce event schemas (Ampli)

The Ampli CLI, Ampli Wrapper, and Amplitude SDK work together to generate a tracking library based on your Tracking Plan. The autogenerated library provides type safety, supports linting, and enable features like input validation which contextualizes your analytics instrumentation, and reduces instrumentation mistakes.

For more information, see Ampli for Node SDK or examples on GitHub for:

ampli.load();
 
ampli.yourEventType('ampli-user-id', {
stringProp: 'Strongly typed property',
booleanProp: true,
});
ampli.load();
 
ampli.yourEventType('ampli-user-id', {
stringProp: 'Strongly typed property',
booleanProp: true,
});

Android

The Android SDK sends events to Amplitude. For more information, see the Android-Kotlin SDK documentation for more configuration options and advanced topics.

Get started with an example project

Kotlin Android example project

To get started fast, check out an example Kotlin Android project:

  1. Clone the repo.
  2. Open it with Android Studio.
  3. Change your API key in build.gradle for Module: samples: kotlin-android-app under Gradle Scripts.
  4. Sync the project with Gradle files.
  5. Run samples.kotlin-android-app.
  6. Press the button to send events in the running application.

Java Android example project

To get started fast, check out an example Java Android project:

  1. Clone the repo.
  2. Open it with Android Studio.
  3. Change your API key in build.gradle for Module: samples: java-android-app under Gradle Scripts.
  4. Sync the project with Gradle files.
  5. Run samples.java-android-app.
  6. Press the button to send events in the running application.

Kotlin JVM example project

To get started fast, check out an example Kotlin JVM project:

  1. Clone the repo.
  2. Open it with Android Studio.
  3. Change your API key in samples/kotlin-jvm-app/main/java/main.kt and run the file.

Install the dependency

dependencies {
implementation 'com.amplitude:analytics-android:1.+'
}
<dependency>
<groupId>com.amplitude</groupId>
<artifactId>analytics-android</artifactId>
<version>[1.0,2.0)</version>
</dependency>

Add permissions

After you install the library, add the following to AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET" />

For Android 6.0 (Marshmallow) and higher, explicitly add permission to fetch the device advertising ID.

The SDK internally uses a few Java 8 language APIs through desugaring. Make sure your project either enables desugaring or requires a minimum API level of 16.

Initialize the SDK

Before you instrument,initialize the SDK using the API Key for your Amplitude project.

Amplitude recommends doing the initialization in the Main Activity, which never gets destroyed, or the Application class if you have one. After it's initialized, you can use the Android SDK anywhere in your Android application.

Note

For EU data residency, the project must be set up inside Amplitude EU. Initialize the SDK with the API key from Amplitude EU.

import com.amplitude.android.Amplitude
 
val amplitude = Amplitude(
Configuration(
apiKey = AMPLITUDE_API_KEY,
context = applicationContext
)
)

Configure the serverZone property to configure your application to use European data residency.

import com.amplitude.android.Amplitude
 
val amplitude = Amplitude(
Configuration(
apiKey = AMPLITUDE_API_KEY,
context = applicationContext,
serverZone = ServerZone.EU
)
)
import com.amplitude.android.Amplitude;
 
Amplitude amplitude = new Amplitude(new Configuration(
apiKey = AMPLITUDE_API_KEY,
context = applicationContext
));

Configure the serverZone property to configure your application to use European data residency.

import com.amplitude.android.Amplitude;
 
Amplitude amplitude = new Amplitude(new Configuration(
apiKey = AMPLITUDE_API_KEY,
context = applicationContext,
serverZone = ServerZone.EU
));

Send data

Next, send data from your app or website to Amplitude.

Events tracked are buffered locally and flushed every 30 seconds. After calling track() in your app, it may take several seconds for event data to appear in Amplitude.

// Track a basic event
amplitude.track("Button Clicked")
// Track events with optional properties
amplitude.track(
"Button Clicked",
mapOf("buttonColor" to "primary")
)
// Track a basic event
amplitude.track("Button Clicked");
// Track events with optional properties
amplitude.track("Button Clicked", new HashMap() {{
put("buttonColor", "primary");
}});

Check for success

After you begin sending data to Amplitude, use one of the debugging tools to check your instrumentation and validate your events.

Complete code example

Here's a complete example of how to use the SDK in your own app.

package com.amplitude.android.sample
 
import android.os.Bundle
import com.amplitude.core.events.Identify
import com.amplitude.android.Amplitude
import com.amplitude.android.Configuration
 
class MainActivity : AppCompatActivity() {
private val amplitude = Amplitude(
Configuration(
apiKey = AMPLITUDE_API_KEY,
context = applicationContext
)
);
 
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
 
val identify = Identify()
identify.set("user-platform", "android")
amplitude.identify(identify)
 
amplitude.track("test event properties", mapOf("test" to "test event property value"))
}
}
package com.amplitude.android.sample;
 
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.amplitude.android.Amplitude;
import com.amplitude.core.events.Identify;
import java.util.HashMap;
 
public class MainActivity extends AppCompatActivity {
 
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Amplitude amplitude = new Amplitude(new Configuration(
apiKey = AMPLITUDE_API_KEY,
context = applicationContext
));
 
Identify identify = new Identify().set("user-platform", "android")
amplitude.identify(identify);
 
amplitude.track("test event properties", new HashMap() {{
put("test", "test event property value");
}});
}
}

For more information, see Android-Kotlin SDK.

Enforce event schemas (Ampli)

The Ampli CLI, Ampli Wrapper, and Amplitude SDK work together to generate a tracking library based on your Tracking Plan. The autogenerated library provides type safety, supports linting, and enable features like input validation which contextualizes your analytics instrumentation, and reduces instrumentation mistakes.

For more information, see Ampli for Android-Kotlin SDK or examples on GitHub for:

ampli.load()
 
ampli.yourEventType(
stringProp = "Strongly typed property",
booleanProp = true
)
Ampli.getInstance().load();
 
Ampli.getInstance().yourEventType(
YourEventType.builder()
.stringProp("Strongly typed property")
.booleanProp(true)
.build()
);

iOS

The iOS SDK sends events to Amplitude. For more information, see the iOS Swift SDK documentation for more configuration options and advanced topics.

Install the dependency

  1. Add the dependency to your Podfile:

    pod 'AmplitudeSwift', '~> 1.0'
  2. Run pod install in the project directory.

  1. Navigate to File > Swift Package Manager > Add Package Dependency. This opens a dialog that allows you to add a package dependency.
  2. Enter the URL https://github.com/amplitude/Amplitude-Swift in the search bar.
  3. Xcode will automatically resolve to the latest version. Or you can select a specific version.
  4. Click the "Next" button to confirm the addition of the package as a dependency.
  5. Build your project to make sure the package is properly integrated.

Add the following line to your Cartfile.

github "amplitude/Amplitude-Swift" ~> 1.0

Check out the Carthage docs for more info.

Install the Amplitude Analytics iOS SDK with CocoaPods, Carthage, or Swift Package Manager

Initialize the SDK

Before you instrument,initialize the SDK using the API Key for your Amplitude project.

Note

For EU data residency, the project must be set up inside Amplitude EU. Initialize the SDK with the API key from Amplitude EU.

import AmplitudeSwift
 
let amplitude = Amplitude(
configuration: Configuration(
apiKey: "YOUR-API-KEY"
)
)

Configure the serverZone property to configure your application to use European data residency.

import AmplitudeSwift
 
let amplitude = Amplitude(
Configuration(
apiKey: "YOUR-API-KEY",
serverZone: ServerZone.EU
)
)
@import AmplitudeSwift;
 
AMPConfiguration* configuration = [AMPConfiguration initWithApiKey:@"YOUR-API-KEY"];
Amplitude* amplitude = [Amplitude initWithConfiguration:configuration];

Configure the serverZone property to configure your application to use European data residency.

@import AmplitudeSwift;
 
AMPConfiguration* configuration = [AMPConfiguration initWithApiKey:@"YOUR-API-KEY"];
configuration.serverZone = AMPServerZoneEU;
Amplitude* amplitude = [Amplitude initWithConfiguration:configuration];

Send data

Next, send data from your app or website to Amplitude.

amplitude.track(
eventType: "Button Clicked",
eventProperties: ["my event prop key": "my event prop value"]
)
[amplitude track:@"Button Clicked" eventProperties:@{
@"my event prop key": @"my event prop value"
}];

Check for success

After you begin sending data to Amplitude, use one of the debugging tools to check your instrumentation and validate your events.

Complete code example

Here's a complete example of how to use the SDK in your own app.

import AmplitudeSwift
 
let amplitude = Amplitude(
configuration: Configuration(
apiKey: "YOUR-API-KEY"
)
)
 
amplitude.track(
eventType: "Button Clicked",
eventProperties: ["my event prop key": "my event prop value"]
)
@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"
}];

For more information, see iOS Swift SDK.

Enforce event schemas (Ampli)

The Ampli CLI, Ampli Wrapper, and Amplitude SDK work together to generate a tracking library based on your Tracking Plan. The autogenerated library provides type safety, supports linting, and enable features like input validation which contextualizes your analytics instrumentation, and reduces instrumentation mistakes.

For more information, see Ampli for iOS Swift SDK or examples on GitHub for:

JRE

The JRE SDK sends events to Amplitude. For more information, see the JRE Java SDK documentation for more configuration options and advanced topics.

Install the dependency

If you use Gradle in your project, add the following dependency to build.gradle, and sync your project with the updated file.

dependencies {
implementation 'org.json:json:20201115'
implementation 'com.amplitude:java-sdk:1.+'
}

Download the latest JAR file then add it to the project's build path. See instructions for your IDE.

Initialize the SDK

Before you instrument,initialize the SDK using the API Key for your Amplitude project.

Import Amplitude into any file that uses it. Amplitude uses the open source JSONObject library to conveniently create JSON key-value objects.

Note

For EU data residency, the project must be set up inside Amplitude EU. Initialize the SDK with the API key from Amplitude EU.

import com.amplitude.Amplitude;
import org.json.JSONObject;
 
Amplitude amplitude = Amplitude.getInstance();
amplitude.init(AMPLITUDE_API_KEY);

Configure the setServerUrl property to configure your application to use European data residency.

import com.amplitude.Amplitude;
import org.json.JSONObject;
 
Amplitude amplitude = Amplitude.getInstance();
amplitude.init(AMPLITUDE_API_KEY);
amplitude.setServerUrl("https://api.eu.amplitude.com/2/httpapi"); //[tl !~~]
import com.amplitude.Amplitude
import org.json.JSONObject
 
val amplitude = Amplitude.getInstance()
amplitude.init(AMPLITUDE_API_KEY)

Configure the setServerUrl property to configure your application to use European data residency.

import com.amplitude.Amplitude
import org.json.JSONObject
 
val amplitude = Amplitude.getInstance()
amplitude.init(AMPLITUDE_API_KEY)
amplitude.setServerUrl("https://api.eu.amplitude.com/2/httpapi"); //[tl !~~]

Send data

Next, send data from your app or website to Amplitude.

amplitude.logEvent(new Event("Button Clicked", "test_user_id"));
amplitude.logEvent(Event("Button Clicked", "test_user_id"))

Check for success

After you begin sending data to Amplitude, use one of the debugging tools to check your instrumentation and validate your events.

Complete code example

Here's a complete example of how to use the SDK in your own app.

import com.amplitude.Amplitude;
import org.json.JSONObject;
 
Amplitude amplitude = Amplitude.getInstance();
amplitude.init(AMPLITUDE_API_KEY);
 
Event event = new Event("Button Clicked", "test_user_id");
 
JSONObject eventProps = new JSONObject();
try {
eventProps.put("Hover Time", 10).put("prop_2", "value_2");
} catch (JSONException e) {
System.err.println("Invalid JSON");
e.printStackTrace();
}
event.eventProperties = eventProps;
 
amplitude.logEvent(event);
import com.amplitude.Amplitude
import org.json.JSONObject
 
val amplitude = Amplitude.getInstance()
amplitude.init(AMPLITUDE_API_KEY)
 
val eventProps= JSONObject()
eventProps.put("Hover Time", 10).put("prop_2", "value_2")
 
val event = Event("Button Clicked", "test_user_id")
event.eventProperties = eventProps
 
amplitude.logEvent(event)

For more information, see JRE Java SDK.

Enforce event schemas (Ampli)

The Ampli CLI, Ampli Wrapper, and Amplitude SDK work together to generate a tracking library based on your Tracking Plan. The autogenerated library provides type safety, supports linting, and enable features like input validation which contextualizes your analytics instrumentation, and reduces instrumentation mistakes.

For more information, see Ampli for Java SDK or examples on GitHub for:

Ampli.getInstance().load();
 
Ampli.getInstance().yourEventType("ampli-user-id",
YourEventType.builder("Strongly typed property")
.stringProp()
.booleanProp(false)
.build()
);
Ampli.getInstance().load()
 
Ampli.getInstance().yourEventType("ampli-user-id",
YourEventType(
stringProp = "Strongly typed property",
booleanProp = false
)
)

Python

The Python SDK sends events to Amplitude. For more information, see the Python SDK documentation for more configuration options and advanced topics.

Install the dependency

Install amplitude-analytics with pip:

pip install amplitude-analytics

Initialize the SDK

Before you instrument,initialize the SDK using the API Key for your Amplitude project.

from amplitude import Amplitude
 
amplitude = Amplitude(AMPLITUDE_API_KEY)

Note

For EU data residency, the project must be set up inside Amplitude EU. Initialize the SDK with the API key from Amplitude EU.

Configure server_zone when you initialize the client to send data to Amplitude's EU servers.

from amplitude import Amplitude
 
amplitude = Amplitude(AMPLITUDE_API_KEY)
amplitude.configuration.server_zone = 'EU' //[tl! ~~]

Send data

Next, send data from your app or website to Amplitude.

from amplitude import BaseEvent
 
amplitude.track(
BaseEvent(
event_type="type of event",
user_id="USER_ID",
device_id="DEVICE_ID",
event_properties={
"source": "notification"
}
)
)

Check for success

After you begin sending data to Amplitude, use one of the debugging tools to check your instrumentation and validate your events.

Complete code example

Here's a complete example of how to use the SDK in your own app.

from amplitude import Amplitude, Identify, BaseEvent
 
amplitude = Amplitude("AMPLITUDE_API_KEY")
 
identify_obj=Identify()
identify_obj.set("location", "LAX")
amplitude.identify(identify_obj)
 
amplitude.track(
BaseEvent(
event_type="type of event",
user_id="USER_ID",
device_id="DEVICE_ID",
event_properties={
"source": "notification"
}
)
)
 
# Flush the event buffer
amplitude.flush()
 
# Shutdown the client, recommend to call before program exit
amplitude.shutdown()

For more information, see Python SDK.

Enforce event schemas (Ampli)

The Ampli CLI, Ampli Wrapper, and Amplitude SDK work together to generate a tracking library based on your Tracking Plan. The autogenerated library provides type safety, supports linting, and enable features like input validation which contextualizes your analytics instrumentation, and reduces instrumentation mistakes.

For more information, see Ampli for Python SDK or examples on GitHub for:

ampli.load()
 
ampli.yourEventType(
"user_id",
YourEventType(
stringProp= "Strongly typed property",
booleanProp=True
)
)

React Native

The React Native SDK sends events to Amplitude. For more information, see the React Native SDK documentation for more configuration options and advanced topics.

Install the dependency

npm install @amplitude/analytics-react-native
npm install @react-native-async-storage/async-storage
yarn add @amplitude/analytics-react-native
yarn add @react-native-async-storage/async-storage
expo install @amplitude/analytics-react-native
expo install @react-native-async-storage/async-storage

Install the native modules to run the SDK on iOS.

cd ios
pod install

Initialize the SDK

Before you instrument,initialize the SDK using the API Key for your Amplitude project.

import { init } from '@amplitude/analytics-react-native';
 
init(AMPLITUDE_API_KEY, 'user@amplitude.com');
import { init } from '@amplitude/analytics-react-native';
 
init(AMPLITUDE_API_KEY, 'user@amplitude.com');

Send data

Next, send data from your app or website to Amplitude.

import { track } from '@amplitude/analytics-react-native';
 
const eventProperties = {
buttonColor: 'primary',
};
track('Button Clicked', eventProperties);
import { track } from '@amplitude/analytics-react-native';
 
const eventProperties = {
buttonColor: 'primary',
};
track('Button Clicked', eventProperties);

Check for success

After you begin sending data to Amplitude, use one of the debugging tools to check your instrumentation and validate your events.

Complete code example

Here's a complete example of how to use the SDK in your own app.

import { init, track, Identify, identify } from '@amplitude/analytics-react-native';
 
init(AMPLITUDE_API_KEY, 'user@amplitude.com');
 
const identifyObj = new Identify();
identifyObj.set('location', 'LAX');
identify(identifyObj);
 
const eventProperties = {
buttonColor: 'primary',
};
track('Button Clicked', eventProperties);
import { init, track, Identify, identify } from '@amplitude/analytics-react-native';
 
init(AMPLITUDE_API_KEY, 'user@amplitude.com');
 
const identifyObj = new Identify();
identifyObj.set('location', 'LAX');
identify(identifyObj);
 
const eventProperties = {
buttonColor: 'primary',
};
track('Button Clicked', eventProperties);

For more information, see React Native SDK.

Enforce event schemas (Ampli)

The Ampli CLI, Ampli Wrapper, and Amplitude SDK work together to generate a tracking library based on your Tracking Plan. The autogenerated library provides type safety, supports linting, and enable features like input validation which contextualizes your analytics instrumentation, and reduces instrumentation mistakes.

For more information, see Ampli for the React Native SDK or examples on GitHub for:

ampli.load();
 
ampli.yourEventType({
stringProp: 'Strongly typed property',
});
ampli.load();
 
ampli.yourEventType({
stringProp: 'Strongly typed property',
});

Flutter

The Flutter SDK sends events to Amplitude. For more information, see the Flutter SDK 3 documentation for more configuration options and advanced topics.

Install the dependency

dependencies:
amplitude_flutter: ^3.13.0

For iOS installation, add platform :ios, '10.0' to your Podfile.

Initialize the SDK

Before you instrument,initialize the SDK using the API Key for your Amplitude project.

import 'package:amplitude_flutter/amplitude.dart';
 
final Amplitude amplitude = Amplitude.getInstance();
amplitude.init(AMPLITUDE_API_KEY);

Send data

Next, send data from your app or website to Amplitude.

amplitude.logEvent('BUTTON_CLICKED', {"Hover Time": "100ms"});

Check for success

After you begin sending data to Amplitude, use one of the debugging tools to check your instrumentation and validate your events.

Complete code example

Here's a complete example of how to use the SDK in your own app.

import 'package:amplitude_flutter/amplitude.dart';
import 'package:amplitude_flutter/identify.dart';
 
class YourClass {
Future<void> exampleForAmplitude() async {
final Amplitude amplitude = Amplitude.getInstance();
 
amplitude.init(AMPLITUDE_API_KEY);
 
final Identify identify1 = Identify();
identify1.setOnce('sign_up_date', '2015-08-24');
Amplitude.getInstance().identify(identify1);
 
amplitude.logEvent('MyApp startup', eventProperties: {
'friend_num': 10,
'is_heavy_user': true
});
}

For more information, see Flutter SDK 3.

Go

The Go SDK sends events to Amplitude. For more information, see the Go SDK documentation for more configuration options and advanced topics.

Install the dependency

go get github.com/amplitude/analytics-go

Initialize the SDK

Before you instrument,initialize the SDK using the API Key for your Amplitude project.

import (
"github.com/amplitude/analytics-go/amplitude"
)
 
config := amplitude.NewConfig(AMPLITUDE_API_KEY)
 
client := amplitude.NewClient(config)

Send data

Next, send data from your app or website to Amplitude.

client.Track(amplitude.Event{
EventType: "Button Clicked",
EventOptions: amplitude.EventOptions{
UserID: "user-id",
DeviceID: "device-id",
},
EventProperties: map[string]interface{}{"source": "notification"},
})

Check for success

After you begin sending data to Amplitude, use one of the debugging tools to check your instrumentation and validate your events.

Complete code example

Here's a complete example of how to use the SDK in your own app.

package main
 
import (
"github.com/amplitude/analytics-go/amplitude"
)
 
func main() {
config := amplitude.NewConfig(AMPLITUDE_API_KEY)
client := amplitude.NewClient(config)
 
identifyObj := amplitude.Identify{}
identifyObj.Set("location", "LAX")
client.Identify(identifyObj, amplitude.EventOptions{UserID: "user-id"})
 
client.Track(amplitude.Event{
EventType: "Button Clicked",
EventOptions: amplitude.EventOptions{
UserID: "user-id",
DeviceID: "device-id",
},
EventProperties: map[string]interface{}{"source": "notification"},
})
}

For more information, see Go SDK.

Enforce event schemas (Ampli)

The Ampli CLI, Ampli Wrapper, and Amplitude SDK work together to generate a tracking library based on your Tracking Plan. The autogenerated library provides type safety, supports linting, and enable features like input validation which contextualizes your analytics instrumentation, and reduces instrumentation mistakes.

For more information, see Ampli for Go or examples on GitHub for:

import "<your-module-name>/ampli"
 
ampli.Instance.Load(ampli.LoadOptions{
Client: ampli.LoadClientOptions{
Configuration: ampli.NewClientConfig(AMPLITUDE_API_KEY),
},
})

Unity

The Unity SDK sends events to Amplitude. For more information, see the Unity SDK documentation for more configuration options and advanced topics.

The Amplitude Analytics Unity SDK is a plugin to simplify the integration of Amplitude iOS and Android SDKs into your Unity project. This SDK works with Unity 2019.3.11 and higher.

Install the dependency

  1. Make sure you have Git installed.
  2. In Unity, click Window > Package Manager.
  3. Click the plus + sign and select Add package from Git URL.
  4. Enter https://github.com/amplitude/unity-plugin.git?path=/Assets, and then click Add.
  5. The Unity editor imports the package from Git.
  1. Download the latest amplitude-unity.unitypackage from GitHub releases.
  2. Double click amplitude-unity.unitypackage to import the package into your Unity project.

Initialize the SDK

Before you instrument,initialize the SDK using the API Key for your Amplitude project.

Amplitude amplitude = Amplitude.getInstance()
amplitude.init("YOUR_API_KEY");

Send data

Next, send data from your app or website to Amplitude.

import 'package:amplitude_flutter/amplitude.dart';
 
amplitude.logEvent('MyApp startup', eventProperties: {
'friend_num': 10,
'is_heavy_user': true
});

Check for success

After you begin sending data to Amplitude, use one of the debugging tools to check your instrumentation and validate your events.

Complete code example

Here's a complete example of how to use the SDK in your own app.

Amplitude amplitude = Amplitude.getInstance();
amplitude.init("AMPLITUDE_API_KEY");
 
amplitude.addUserProperty("oranges", 5);
Dictionary<string, object> values = new Dictionary<string, object>();
values.Add("Key A", "Value A");
amplitude.addUserPropertyDict("user_facts", values);
 
JSONObjecteventProperties=newJSONObject().put("key", "value");
Amplitude.getInstance().logEvent("initialize_game", eventProperties);

For more information, see Unity SDK.

Unreal

The Unreal SDK sends events to Amplitude. For more information, see the Unreal SDK documentation for more configuration options and advanced topics.

The Amplitude Analytics Unreal Engine SDK supports projects targeting iOS, MacOS, or tvOS.

Install the dependency

Install the Unreal Engine SDK by downloading the latest version of AmplitudeUnreal.zip found on the GitHub releases page.
Unzip it into a folder inside your Unreal project's Plugins directory.

mkdir -p Plugins/AmplitudeUnreal
unzip AmplitudeUnreal.zip -d Plugins/AmplitudeUnreal

Initialize the SDK

Before you instrument,initialize the SDK using the API Key for your Amplitude project.

  1. In Unreal, navigate to Settings > Plugins > Project > Analytics to enable the plugin. Learn more about how to enable SDK plugin.
  2. Navigate to Settings -> Project Settings -> Analytics -> Providers to set Amplitude as your analytics provider. Learn more about how to set analytics provider.
  3. Navigate to Settings -> Project Settings -> Analytics -> Amplitude to set API keys. Learn more about how to set API keys.
  4. Add the following code:
#include "Runtime/Analytics/Analytics/Public/Analytics.h"
#include "Runtime/Analytics/Analytics/Public/Interfaces/IAnalyticsProvider.h"

Send data

Next, send data from your app or website to Amplitude.

TArray<FAnalyticsEventAttribute> AppendedAttributes;
AppendedAttributes.Emplace(TEXT("Test Event Prop key1"), TEXT("Test Event value1"));
AppendedAttributes.Emplace(TEXT("Test Event Prop key2"), TEXT("Test Event value2"));
FAnalytics::Get().GetDefaultConfiguredProvider()->RecordEvent(TEXT("Game Started"), AppendedAttributes);

Check for success

After you begin sending data to Amplitude, use one of the debugging tools to check your instrumentation and validate your events.

Complete code example

Here's a complete example of how to use the SDK in your own app.

FAnalytics::Get().GetDefaultConfiguredProvider()->SetLocation(TEXT("Test location"));
FAnalytics::Get().GetDefaultConfiguredProvider()->SetGender(TEXT("Test gender"));
FAnalytics::Get().GetDefaultConfiguredProvider()->SetAge(TEXT(27));
 
TArray<FAnalyticsEventAttribute> AppendedAttributes;
AppendedAttributes.Emplace(TEXT("Test Event Prop key1"), TEXT("Test Event value1"));
AppendedAttributes.Emplace(TEXT("Test Event Prop key2"), TEXT("Test Event value2"));
FAnalytics::Get().GetDefaultConfiguredProvider()->RecordEvent(TEXT("Game Started"), AppendedAttributes);

For more information, see Unreal SDK.

Was this page helpful?

July 11th, 2024

Need help? Contact Support

Visit Amplitude.com

Have a look at the Amplitude Blog

Learn more at Amplitude Academy

© 2025 Amplitude, Inc. All rights reserved. Amplitude is a registered trademark of Amplitude, Inc.