The Browser SDK sends events to Amplitude. For more information, see the Browser SDK 2 documentation for more configuration options and advanced topics.
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.
1npm install @amplitude/analytics-browser
Import Amplitude into your project:
1import * as amplitude from '@amplitude/analytics-browser';
1yarn add @amplitude/analytics-browser
Import Amplitude into your project:
1import * as amplitude from '@amplitude/analytics-browser';
Install the dependency using NPM, YARN, or script loader.
Before you instrument,initialize the SDK using the API Key for your Amplitude project.
1amplitude.init(AMPLITUDE_API_KEY);
Next, send data from your app or website to Amplitude.
1const eventProperties = {2 buttonColor: 'primary',3};4amplitude.track('Button Clicked', eventProperties);
After you begin sending data to Amplitude, use one of the debugging tools to check your instrumentation and validate your events.
Here's a complete example of how to use the SDK in your own app.
1amplitude.init(AMPLITUDE_API_KEY, 'user@amplitude.com'); 2const eventProperties = { 3 buttonColor: 'primary', 4}; 5 6const identifyObj = new Identify(); 7identifyObj.set('location', 'LAX'); 8amplitude.identify(identifyObj); 9 10amplitude.track('Button Clicked', eventProperties);
For more information, see Browser SDK 2.
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:
1import { ampli } from './ampli';2ampli.load({ client: { apiKey: AMPLITUDE_API_KEY } });3 4ampli.buttonClicked({5 buttonColor: 'primary',6});
The Node SDK sends events to Amplitude. For more information, see the Node SDK documentation for more configuration options and advanced topics.
1npm install @amplitude/analytics-node
1yarn add @amplitude/analytics-node
Install the dependency with npm or yarn.
Before you instrument,initialize the SDK using the API Key for your Amplitude project.
1import { init } from '@amplitude/analytics-node';2 3init(AMPLITUDE_API_KEY);
1import { init } from '@amplitude/analytics-node';2 3init(AMPLITUDE_API_KEY);
Next, send data from your app or website to Amplitude.
1import { track } from '@amplitude/analytics-node';2 3const eventProperties = {4 buttonColor: 'primary',5};6 7track('Button Clicked', eventProperties, {8 user_id: 'user@amplitude.com',9});
1import { track } from '@amplitude/analytics-node';2 3const eventProperties = {4 buttonColor: 'primary',5};6 7track('Button Clicked', eventProperties, {8 user_id: 'user@amplitude.com',9});
After you begin sending data to Amplitude, use one of the debugging tools to check your instrumentation and validate your events.
Here's a complete example of how to use the SDK in your own app.
1import { init, identify, Identify, track } from '@amplitude/analytics-node'; 2init(AMPLITUDE_API_KEY); 3 4const identifyObj = new Identify(); 5identify(identifyObj, { 6 user_id: 'user@amplitude.com', 7}); 8 9const eventProperties = {10 buttonColor: 'primary',11};12track('Button Clicked', eventProperties, {13 user_id: 'user@amplitude.com',14});
1import { init, identify, Identify, track } from '@amplitude/analytics-node'; 2init(AMPLITUDE_API_KEY); 3 4const identifyObj = new Identify(); 5identify(identifyObj, { 6 user_id: 'user@amplitude.com', 7}); 8 9const eventProperties = {10 buttonColor: 'primary',11};12track('Button Clicked', eventProperties, {13 user_id: 'user@amplitude.com',14});
For more information, see Node SDK.
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:
1ampli.load();2 3ampli.yourEventType('ampli-user-id', {4 stringProp: 'Strongly typed property',5 booleanProp: true,6});
1ampli.load();2 3ampli.yourEventType('ampli-user-id', {4 stringProp: 'Strongly typed property',5 booleanProp: true,6});
The Android SDK sends events to Amplitude. For more information, see the Android-Kotlin SDK documentation for more configuration options and advanced topics.
To get started fast, check out an example Kotlin Android project: To get started fast, check out an example Java Android project: To get started fast, check out an example Kotlin JVM project:
Get started with an example project
Kotlin Android example project
build.gradle
for Module: samples: kotlin-android-app
under Gradle Scripts.samples.kotlin-android-app
.Java Android example project
build.gradle
for Module: samples: java-android-app
under Gradle Scripts.samples.java-android-app
.Kotlin JVM example project
samples/kotlin-jvm-app/main/java/main.kt
and run the file.
1dependencies {2 implementation 'com.amplitude:analytics-android:1.+'3}
1<dependency>2 <groupId>com.amplitude</groupId>3 <artifactId>analytics-android</artifactId>4 <version>[1.0,2.0)</version>5</dependency>
After you install the library, add the following to AndroidManifest.xml
1<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.
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.
For EU data residency, the project must be set up inside Amplitude EU. Initialize the SDK with the API key from Amplitude EU.
1import com.amplitude.android.Amplitude2 3val amplitude = Amplitude(4 Configuration(5 apiKey = AMPLITUDE_API_KEY,6 context = applicationContext7 )8)
Configure the serverZone
property to configure your application to use European data residency.
1import com.amplitude.android.Amplitude2 3val amplitude = Amplitude(4 Configuration(5 apiKey = AMPLITUDE_API_KEY,6 context = applicationContext,7 serverZone = ServerZone.EU 8 )9)
1import com.amplitude.android.Amplitude;2 3Amplitude amplitude = new Amplitude(new Configuration(4 apiKey = AMPLITUDE_API_KEY,5 context = applicationContext6));
Configure the serverZone
property to configure your application to use European data residency.
1import com.amplitude.android.Amplitude;2 3Amplitude amplitude = new Amplitude(new Configuration(4 apiKey = AMPLITUDE_API_KEY,5 context = applicationContext,6 serverZone = ServerZone.EU 7));
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.
1// Track a basic event2amplitude.track("Button Clicked")3// Track events with optional properties4amplitude.track(5 "Button Clicked",6 mapOf("buttonColor" to "primary")7)
1// Track a basic event2amplitude.track("Button Clicked");3// Track events with optional properties4amplitude.track("Button Clicked", new HashMap() {{5 put("buttonColor", "primary");6}});
After you begin sending data to Amplitude, use one of the debugging tools to check your instrumentation and validate your events.
Here's a complete example of how to use the SDK in your own app.
1package com.amplitude.android.sample 2 3import android.os.Bundle 4import com.amplitude.core.events.Identify 5import com.amplitude.android.Amplitude 6import com.amplitude.android.Configuration 7 8class MainActivity : AppCompatActivity() { 9 private val amplitude = Amplitude(10 Configuration(11 apiKey = AMPLITUDE_API_KEY,12 context = applicationContext13 )14 );15 16 override fun onCreate(savedInstanceState: Bundle?) {17 super.onCreate(savedInstanceState)18 setContentView(R.layout.activity_main)19 20 val identify = Identify()21 identify.set("user-platform", "android")22 amplitude.identify(identify)23 24 amplitude.track("test event properties", mapOf("test" to "test event property value"))25 }26}
1package com.amplitude.android.sample; 2 3import androidx.appcompat.app.AppCompatActivity; 4import android.os.Bundle; 5import com.amplitude.android.Amplitude; 6import com.amplitude.core.events.Identify; 7import java.util.HashMap; 8 9public class MainActivity extends AppCompatActivity {10 11 @Override12 protected void onCreate(Bundle savedInstanceState) {13 super.onCreate(savedInstanceState);14 setContentView(R.layout.activity_main);15 Amplitude amplitude = new Amplitude(new Configuration(16 apiKey = AMPLITUDE_API_KEY,17 context = applicationContext18 ));19 20 Identify identify = new Identify().set("user-platform", "android")21 amplitude.identify(identify);22 23 amplitude.track("test event properties", new HashMap() {{24 put("test", "test event property value");25 }});26 }27}
For more information, see Android-Kotlin SDK.
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:
1ampli.load()2 3ampli.yourEventType(4 stringProp = "Strongly typed property",5 booleanProp = true6)
1Ampli.getInstance().load();2 3Ampli.getInstance().yourEventType(4 YourEventType.builder()5 .stringProp("Strongly typed property")6 .booleanProp(true)7 .build()8);
The iOS SDK sends events to Amplitude. For more information, see the iOS Swift SDK documentation for more configuration options and advanced topics.
Add the dependency to your Podfile
:
1pod 'AmplitudeSwift', '~> 1.0.0'
Run pod install
in the project directory.
File
> Swift Package Manager
> Add Package Dependency
. This opens a dialog that allows you to add a package dependency.https://github.com/amplitude/Amplitude-Swift
in the search bar.Add the following line to your Cartfile
.
1github "amplitude/Amplitude-Swift" ~> 1.0.0
Check out the Carthage docs for more info.
Install the Amplitude Analytics iOS SDK with CocoaPods, Carthage, or Swift Package Manager
Before you instrument,initialize the SDK using the API Key for your Amplitude project.
For EU data residency, the project must be set up inside Amplitude EU. Initialize the SDK with the API key from Amplitude EU.
1import AmplitudeSwift2 3let amplitude = Amplitude(4 configuration: Configuration(5 apiKey: "YOUR-API-KEY"6 )7)
Configure the serverZone
property to configure your application to use European data residency.
1import AmplitudeSwift2 3let amplitude = Amplitude(4 Configuration(5 apiKey: "YOUR-API-KEY",6 serverZone: ServerZone.EU 7 )8)
1@import AmplitudeSwift;2 3AMPConfiguration* configuration = [AMPConfiguration initWithApiKey:@"YOUR-API-KEY"];4Amplitude* amplitude = [Amplitude initWithConfiguration:configuration];
Configure the serverZone
property to configure your application to use European data residency.
1@import AmplitudeSwift;2 3AMPConfiguration* configuration = [AMPConfiguration initWithApiKey:@"YOUR-API-KEY"];4configuration.serverZone = AMPServerZoneEU; 5Amplitude* amplitude = [Amplitude initWithConfiguration:configuration];
Next, send data from your app or website to Amplitude.
1amplitude.track(2 eventType: "Button Clicked",3 eventProperties: ["my event prop key": "my event prop value"]4)
1[amplitude track:@"Button Clicked" eventProperties:@{2 @"my event prop key": @"my event prop value"3}];
After you begin sending data to Amplitude, use one of the debugging tools to check your instrumentation and validate your events.
Here's a complete example of how to use the SDK in your own app.
1import AmplitudeSwift 2 3let amplitude = Amplitude( 4 configuration: Configuration( 5 apiKey: "YOUR-API-KEY" 6 ) 7) 8 9amplitude.track(10 eventType: "Button Clicked",11 eventProperties: ["my event prop key": "my event prop value"]12)
1@import AmplitudeSwift;2 3AMPConfiguration* configuration = [AMPConfiguration initWithApiKey:@"YOUR-API-KEY"];4Amplitude* amplitude = [Amplitude initWithConfiguration:configuration];5 6[amplitude track:@"Button Clicked" eventProperties:@{7 @"my event prop key": @"my event prop value"8}];
For more information, see iOS Swift SDK.
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:
The JRE SDK sends events to Amplitude. For more information, see the JRE Java SDK documentation for more configuration options and advanced topics.
If you use Gradle in your project, add the following dependency to build.gradle
, and sync your project with the updated file.
1dependencies {2 implementation 'org.json:json:20201115'3 implementation 'com.amplitude:java-sdk:1.+'4}
Download the latest JAR file then add it to the project's build path. See instructions for your IDE.
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.
For EU data residency, the project must be set up inside Amplitude EU. Initialize the SDK with the API key from Amplitude EU.
1import com.amplitude.Amplitude;2import org.json.JSONObject;3 4Amplitude amplitude = Amplitude.getInstance();5amplitude.init(AMPLITUDE_API_KEY);
Configure the setServerUrl
property to configure your application to use European data residency.
1import com.amplitude.Amplitude;2import org.json.JSONObject;3 4Amplitude amplitude = Amplitude.getInstance();5amplitude.init(AMPLITUDE_API_KEY);6amplitude.setServerUrl("https://api.eu.amplitude.com/2/httpapi"); //[tl !~~]
1import com.amplitude.Amplitude2import org.json.JSONObject3 4val amplitude = Amplitude.getInstance()5amplitude.init(AMPLITUDE_API_KEY)
Configure the setServerUrl
property to configure your application to use European data residency.
1import com.amplitude.Amplitude2import org.json.JSONObject3 4val amplitude = Amplitude.getInstance()5amplitude.init(AMPLITUDE_API_KEY)6amplitude.setServerUrl("https://api.eu.amplitude.com/2/httpapi"); //[tl !~~]
Next, send data from your app or website to Amplitude.
1amplitude.logEvent(new Event("Button Clicked", "test_user_id"));
1amplitude.logEvent(Event("Button Clicked", "test_user_id"))
After you begin sending data to Amplitude, use one of the debugging tools to check your instrumentation and validate your events.
Here's a complete example of how to use the SDK in your own app.
1import com.amplitude.Amplitude; 2import org.json.JSONObject; 3 4Amplitude amplitude = Amplitude.getInstance(); 5amplitude.init(AMPLITUDE_API_KEY); 6 7Event event = new Event("Button Clicked", "test_user_id"); 8 9JSONObject eventProps = new JSONObject();10try {11 eventProps.put("Hover Time", 10).put("prop_2", "value_2");12} catch (JSONException e) {13 System.err.println("Invalid JSON");14 e.printStackTrace();15}16event.eventProperties = eventProps;17 18amplitude.logEvent(event);
1import com.amplitude.Amplitude 2import org.json.JSONObject 3 4val amplitude = Amplitude.getInstance() 5amplitude.init(AMPLITUDE_API_KEY) 6 7val eventProps= JSONObject() 8eventProps.put("Hover Time", 10).put("prop_2", "value_2") 9 10val event = Event("Button Clicked", "test_user_id")11event.eventProperties = eventProps12 13amplitude.logEvent(event)
For more information, see JRE Java SDK.
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:
1Ampli.getInstance().load();2 3Ampli.getInstance().yourEventType("ampli-user-id",4 YourEventType.builder("Strongly typed property")5 .stringProp()6 .booleanProp(false)7 .build()8);
1Ampli.getInstance().load()2 3Ampli.getInstance().yourEventType("ampli-user-id",4 YourEventType(5 stringProp = "Strongly typed property",6 booleanProp = false7 )8)
The Python SDK sends events to Amplitude. For more information, see the Python SDK documentation for more configuration options and advanced topics.
Install amplitude-analytics
with pip:
1pip install amplitude-analytics
Before you instrument,initialize the SDK using the API Key for your Amplitude project.
1from amplitude import Amplitude2 3amplitude = Amplitude(AMPLITUDE_API_KEY)
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.
1from amplitude import Amplitude2 3amplitude = Amplitude(AMPLITUDE_API_KEY)4amplitude.configuration.server_zone = 'EU' //[tl! ~~]
Next, send data from your app or website to Amplitude.
1from amplitude import BaseEvent 2 3amplitude.track( 4 BaseEvent( 5 event_type="type of event", 6 user_id="USER_ID", 7 device_id="DEVICE_ID", 8 event_properties={ 9 "source": "notification"10 }11 )12)
After you begin sending data to Amplitude, use one of the debugging tools to check your instrumentation and validate your events.
Here's a complete example of how to use the SDK in your own app.
1from amplitude import Amplitude, Identify, BaseEvent 2 3amplitude = Amplitude("AMPLITUDE_API_KEY") 4 5identify_obj=Identify() 6identify_obj.set("location", "LAX") 7amplitude.identify(identify_obj) 8 9amplitude.track(10 BaseEvent(11 event_type="type of event",12 user_id="USER_ID",13 device_id="DEVICE_ID",14 event_properties={15 "source": "notification"16 }17 )18)19 20# Flush the event buffer21amplitude.flush()22 23# Shutdown the client, recommend to call before program exit24amplitude.shutdown()
For more information, see Python SDK.
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:
1ampli.load()2 3ampli.yourEventType(4 "user_id",5 YourEventType(6 stringProp= "Strongly typed property",7 booleanProp=True8 )9)
The React Native SDK sends events to Amplitude. For more information, see the React Native SDK documentation for more configuration options and advanced topics.
1npm install @amplitude/analytics-react-native2npm install @react-native-async-storage/async-storage
1yarn add @amplitude/analytics-react-native2yarn add @react-native-async-storage/async-storage
1expo install @amplitude/analytics-react-native2expo install @react-native-async-storage/async-storage
Install the native modules to run the SDK on iOS.
1cd ios2pod install
Before you instrument,initialize the SDK using the API Key for your Amplitude project.
1import { init } from '@amplitude/analytics-react-native';2 3init(AMPLITUDE_API_KEY, 'user@amplitude.com');
1import { init } from '@amplitude/analytics-react-native';2 3init(AMPLITUDE_API_KEY, 'user@amplitude.com');
Next, send data from your app or website to Amplitude.
1import { track } from '@amplitude/analytics-react-native';2 3const eventProperties = {4 buttonColor: 'primary',5};6track('Button Clicked', eventProperties);
1import { track } from '@amplitude/analytics-react-native';2 3const eventProperties = {4 buttonColor: 'primary',5};6track('Button Clicked', eventProperties);
After you begin sending data to Amplitude, use one of the debugging tools to check your instrumentation and validate your events.
Here's a complete example of how to use the SDK in your own app.
1import { init, track, Identify, identify } from '@amplitude/analytics-react-native'; 2 3init(AMPLITUDE_API_KEY, 'user@amplitude.com'); 4 5const identifyObj = new Identify(); 6identifyObj.set('location', 'LAX'); 7identify(identifyObj); 8 9const eventProperties = {10 buttonColor: 'primary',11};12track('Button Clicked', eventProperties);
1import { init, track, Identify, identify } from '@amplitude/analytics-react-native'; 2 3init(AMPLITUDE_API_KEY, 'user@amplitude.com'); 4 5const identifyObj = new Identify(); 6identifyObj.set('location', 'LAX'); 7identify(identifyObj); 8 9const eventProperties = {10 buttonColor: 'primary',11};12track('Button Clicked', eventProperties);
For more information, see React Native SDK.
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:
1ampli.load();2 3ampli.yourEventType({4 stringProp: 'Strongly typed property',5});
1ampli.load();2 3ampli.yourEventType({4 stringProp: 'Strongly typed property',5});
The Flutter SDK sends events to Amplitude. For more information, see the Flutter SDK documentation for more configuration options and advanced topics.
1dependencies:2 amplitude_flutter: ^3.13.0
For iOS installation, add platform :ios, '10.0'
to your Podfile.
Before you instrument,initialize the SDK using the API Key for your Amplitude project.
1import 'package:amplitude_flutter/amplitude.dart';2 3final Amplitude amplitude = Amplitude.getInstance();4amplitude.init(AMPLITUDE_API_KEY);
Next, send data from your app or website to Amplitude.
1amplitude.logEvent('BUTTON_CLICKED', {"Hover Time": "100ms"});
After you begin sending data to Amplitude, use one of the debugging tools to check your instrumentation and validate your events.
Here's a complete example of how to use the SDK in your own app.
1import 'package:amplitude_flutter/amplitude.dart'; 2import 'package:amplitude_flutter/identify.dart'; 3 4class YourClass { 5 Future<void> exampleForAmplitude() async { 6 final Amplitude amplitude = Amplitude.getInstance(); 7 8 amplitude.init(AMPLITUDE_API_KEY); 9 10 final Identify identify1 = Identify();11 identify1.setOnce('sign_up_date', '2015-08-24');12 Amplitude.getInstance().identify(identify1);13 14 amplitude.logEvent('MyApp startup', eventProperties: {15 'friend_num': 10,16 'is_heavy_user': true17 });18}
For more information, see Flutter SDK.
The Go SDK sends events to Amplitude. For more information, see the Go SDK documentation for more configuration options and advanced topics.
1go get github.com/amplitude/analytics-go
Before you instrument,initialize the SDK using the API Key for your Amplitude project.
1import (2 "github.com/amplitude/analytics-go/amplitude"3)4 5config := amplitude.NewConfig(AMPLITUDE_API_KEY)6 7client := amplitude.NewClient(config)
Next, send data from your app or website to Amplitude.
1client.Track(amplitude.Event{2 EventType: "Button Clicked",3 EventOptions: amplitude.EventOptions{4 UserID: "user-id",5 DeviceID: "device-id",6 },7 EventProperties: map[string]interface{}{"source": "notification"},8})
After you begin sending data to Amplitude, use one of the debugging tools to check your instrumentation and validate your events.
Here's a complete example of how to use the SDK in your own app.
1package main 2 3import ( 4 "github.com/amplitude/analytics-go/amplitude" 5) 6 7func main() { 8 config := amplitude.NewConfig(AMPLITUDE_API_KEY) 9 client := amplitude.NewClient(config)10 11 identifyObj := amplitude.Identify{}12 identifyObj.Set("location", "LAX")13 client.Identify(identifyObj, amplitude.EventOptions{UserID: "user-id"})14 15 client.Track(amplitude.Event{16 EventType: "Button Clicked",17 EventOptions: amplitude.EventOptions{18 UserID: "user-id",19 DeviceID: "device-id",20 },21 EventProperties: map[string]interface{}{"source": "notification"},22 })23}
For more information, see Go SDK.
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:
1import "<your-module-name>/ampli"2 3ampli.Instance.Load(ampli.LoadOptions{4 Client: ampli.LoadClientOptions{5 Configuration: ampli.NewClientConfig(AMPLITUDE_API_KEY),6 },7})
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.
Window > Package Manager
.Add package from Git URL
.https://github.com/amplitude/unity-plugin.git?path=/Assets
, and then click Add.amplitude-unity.unitypackage
from GitHub releases.amplitude-unity.unitypackage
to import the package into your Unity project.Before you instrument,initialize the SDK using the API Key for your Amplitude project.
1Amplitude amplitude = Amplitude.getInstance()2amplitude.init("YOUR_API_KEY");
Next, send data from your app or website to Amplitude.
1import 'package:amplitude_flutter/amplitude.dart';2 3amplitude.logEvent('MyApp startup', eventProperties: {4 'friend_num': 10,5 'is_heavy_user': true6});
After you begin sending data to Amplitude, use one of the debugging tools to check your instrumentation and validate your events.
Here's a complete example of how to use the SDK in your own app.
1Amplitude amplitude = Amplitude.getInstance(); 2amplitude.init("AMPLITUDE_API_KEY"); 3 4amplitude.addUserProperty("oranges", 5); 5Dictionary<string, object> values = new Dictionary<string, object>(); 6values.Add("Key A", "Value A"); 7amplitude.addUserPropertyDict("user_facts", values); 8 9JSONObjecteventProperties=newJSONObject().put("key", "value");10Amplitude.getInstance().logEvent("initialize_game", eventProperties);
For more information, see Unity SDK.
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 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.
1mkdir -p Plugins/AmplitudeUnreal2unzip AmplitudeUnreal.zip -d Plugins/AmplitudeUnreal
Before you instrument,initialize the SDK using the API Key for your Amplitude project.
1#include "Runtime/Analytics/Analytics/Public/Analytics.h"2#include "Runtime/Analytics/Analytics/Public/Interfaces/IAnalyticsProvider.h"
Next, send data from your app or website to Amplitude.
1TArray<FAnalyticsEventAttribute> AppendedAttributes;2AppendedAttributes.Emplace(TEXT("Test Event Prop key1"), TEXT("Test Event value1"));3AppendedAttributes.Emplace(TEXT("Test Event Prop key2"), TEXT("Test Event value2"));4FAnalytics::Get().GetDefaultConfiguredProvider()->RecordEvent(TEXT("Game Started"), AppendedAttributes);
After you begin sending data to Amplitude, use one of the debugging tools to check your instrumentation and validate your events.
Here's a complete example of how to use the SDK in your own app.
1FAnalytics::Get().GetDefaultConfiguredProvider()->SetLocation(TEXT("Test location"));2FAnalytics::Get().GetDefaultConfiguredProvider()->SetGender(TEXT("Test gender"));3FAnalytics::Get().GetDefaultConfiguredProvider()->SetAge(TEXT(27));4 5TArray<FAnalyticsEventAttribute> AppendedAttributes;6AppendedAttributes.Emplace(TEXT("Test Event Prop key1"), TEXT("Test Event value1"));7AppendedAttributes.Emplace(TEXT("Test Event Prop key2"), TEXT("Test Event value2"));8FAnalytics::Get().GetDefaultConfiguredProvider()->RecordEvent(TEXT("Game Started"), AppendedAttributes);
For more information, see Unreal SDK.
Thanks for your feedback!
July 11th, 2024
Need help? Contact Support
Visit Amplitude.com
Have a look at the Amplitude Blog
Learn more at Amplitude Academy
© 2024 Amplitude, Inc. All rights reserved. Amplitude is a registered trademark of Amplitude, Inc.