Skip to content

Amplitude SDK Quickstart Guide

Use this guide to get started with the Amplitude SDKs. Choose your target platform:

The Browser SDK lets you send events to Amplitude. See the Browser SDK documentation for additional configurations and advanced topics.


Initialize the library


First, install dependencies and initialize the library in your app.

Install the dependency

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

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 to your project

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

Import Amplitude to your project

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

Initialization

Before you can instrument, you must 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);

Learn more available functionalities in Browser 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.

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

ampli.buttonClicked({
    buttonColor: 'primary',
});

Learn more about and set up the Browser Ampli.

The Node.js SDK lets you send events to Amplitude. See the Node.js SDK documentation for additional configurations and advanced topics.


Initialize the library


First, install dependencies and initialize the library in your app.

Install the dependency

Install the dependency using NPM or YARN.

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

Initialization

Before you can instrument, you must 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',
});

Learn more available functionalities in Node.js 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.

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,
});

Learn more about Node Ampli.

The Android SDK lets you send events to Amplitude. See the Android SDK documentation for additional configurations and advanced topics.

Get started fast with an example project (click to expand)
Kotlin Android example project (click to expand)

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.
  7. Check for success.
Java Android example project (click to expand)

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.
  7. Check for success.
Kotlin JVM example project (click to expand)

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.
  4. Check for success.


Initialize the library


First, install dependencies and initialize the library in your app.

Install the dependency

Amplitude recommends using Android Studio as an IDE and Gradle to manage dependencies.

If you are using Gradle in your project, include the following dependencies in build.gradle file. And then sync project with Gradle files.

dependencies {
    implementation 'com.amplitude:analytics-android:1.+'
}

If you are using Maven in your project, the jar is available on Maven Central using the following configuration in your pom.xml

<dependency>
    <groupId>com.amplitude</groupId>
    <artifactId>analytics-android</artifactId>
    <version>[1.0,2.0)</version>
</dependency>

Add permissions

To report events to Amplitude, add the INTERNET permission to your AndroidManifest.xml file.

<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.

Initialization

Before you can instrument, you must 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.

import com.amplitude.android.Amplitude

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

Amplitude amplitude =  new Amplitude(new Configuration(
    apiKey = AMPLITUDE_API_KEY,
    context = applicationContext
));

EU data residency

You can configure the server zone when initializing the client for sending data to Amplitude's EU servers. The SDK sends data based on the server zone if it's set.

Note

For EU data residency, the project must be set up inside Amplitude EU. You must 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,
        serverZone = ServerZone.EU
    )
)
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");
        }});
    }
}

Learn more available functionalities in Android 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.

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()
);

Learn more about Ampli Android.

The iOS SDK lets you send events to Amplitude. See the iOS SDK documentation for additional configurations and advanced topics.


Initialize the library


First, install dependencies and initialize the library in your app.

Install the dependency

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

  1. Add dependency to Podfile.
    pod 'AmplitudeSwift', '~> 1.0.0'
    
  2. Run pod install in the project directory to install the dependency.
  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.0
Check out the Carthage docs for more info.

Initialization

Before you can instrument, you must initialize the SDK using the API key for your Amplitude project.

import AmplitudeSwift

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

AMPConfiguration* configuration = [AMPConfiguration initWithApiKey:@"YOUR-API-KEY"];
Amplitude* amplitude = [Amplitude initWithConfiguration:configuration];

EU data residency

You can configure the server zone when initializing the client for sending data to Amplitude's EU servers. The SDK sends data based on the server zone if it's set.

Note

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

import AmplitudeSwift

let amplitude = Amplitude(
    Configuration(
        apiKey: "YOUR-API-KEY",
        serverZone: ServerZone.EU
    )
)
@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"
}];

Learn more available functionalities in iOS 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.

This is the documentation for the Amplitude Analytics Java SDK. This is not the Android SDK. See the Java SDK documentation for additional configurations and advanced topics.


Initialize the library


First, install dependencies and initialize the library in your app.

Install the dependency

If you are using Gradle in your project, include the following dependencies in build.gradle file. And then sync project with Gradle files.

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

Download the latest JAR file and add it to the project's buildpath. See instructions for your IDE.

Initialization

Before you can instrument, you must 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.

import com.amplitude.Amplitude;
import org.json.JSONObject;

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

val amplitude = Amplitude.getInstance()
amplitude.init(AMPLITUDE_API_KEY)

EU data residency

You can configure the server zone when initializing the client for sending data to Amplitude's EU servers. The SDK sends data based on the server zone if it's set.

Note

For EU data residency, the project must be set up inside Amplitude EU. You must 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);
amplitude.setServerUrl("https://api.eu.amplitude.com/2/httpapi");
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");


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)

Learn more in 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.

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
    )
)

Learn more about Ampli Java.

The Python SDK lets you send events to Amplitude. See the Python SDK documentation for additional configurations and advanced topics.


Initialize the library


First, install dependencies and initialize the library in your app.

Install the dependency

Install amplitude-analytics using pip:

pip install amplitude-analytics

Initialization

Before you can instrument, you must initialize the SDK using the API key for your Amplitude project.

from amplitude import Amplitude

amplitude = Amplitude(AMPLITUDE_API_KEY)

EU data residency

You can configure the server zone when initializing the client for sending data to Amplitude's EU servers. The SDK sends data based on the server zone if it's set.

Note

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

from amplitude import Amplitude

amplitude = Amplitude(AMPLITUDE_API_KEY)
amplitude.configuration.server_zone = 'EU'


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()

Learn more available functionalities in 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.

ampli.load()

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

Learn more about Ampli Python.

The React Native SDK lets you send events to Amplitude. See the React Native SDK documentation for additional configurations and advanced topics.


Initialize the library


First, install dependencies and initialize the library in your app.

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

Initialization

Before you can instrument, you must 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);

Learn more available functionalities in 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.

ampli.load();

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

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

Learn more about Ampli React Native.

The Flutter SDK lets you send events to Amplitude. See the Flutter SDK documentation for additional configurations and advanced topics.


Initialize the library


First, install dependencies and initialize the library in your app.

Install the dependency

dependencies:
    amplitude_flutter: ^3.13.0

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

Learn more about adding the dependency.

Initialization

Before you can instrument, you must 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
    });
}

Learn more in Flutter 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.

More information TBD.

The Go SDK lets you send events to Amplitude. See the Go SDK documentation for additional configurations and advanced topics.


Initialize the library


First, install dependencies and initialize the library in your app.

Install the dependency

go get github.com/amplitude/analytics-go

Initialization

Before you can instrument, you must 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"},
    })
}

Learn more available functionalities in 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.

Coming soon.

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. See the Unity SDK documentation for additional configurations and advanced topics.


Initialize the library


First, install dependencies and initialize the library in your app.

Install the dependency

Add 'https://github.com/amplitude/unity-plugin.git?path=/Assets'.
Learn more about Unity package manager initialization

Download amplitude-unity.unitypackage

Learn more about the Unity package download.

Initialization

Before you can instrument, you must 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);

Learn more in Unity 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.

More information TBD.

The Amplitude Analytics Unreal Engine SDK supports projects targeting iOS, MacOS, or tvOS. See the Unreal Engine SDK documentation for additional configurations and advanced topics.


Initialize the library


First, install dependencies and initialize the library in your app.

Install the dependency

Download SDK and add to project

  1. Download AmplitudeUnreal.zip.
  2. Unzip it into a folder inside your Unreal project's Plugins directory.

Download the latest AmplitudeUnreal.zip.

Initialization

Before you can instrument, you must initialize the SDK using the API key for your Amplitude project.

Enable the SDK plugin

Settings > Plugins > Project > Analytics

Learn more about how to enable SDK plugin.

Set Amplitude as your analytics provider

Settings -> Project Settings -> Analytics -> Providers

Learn more about how to set analytics provider.

Add your API keys

Settings -> Project Settings -> Analytics -> Amplitude

Learn more about how to set API keys.

#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);

Learn more in Unreal 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.

More information TBD.


Was this page helpful?