SDKs overview

Amplitude provides a suite of Software Development Kits (SDKs) designed to facilitate the collection of event data from various applications and platforms. These SDKs abstract much of the complexity involved in sending data to Amplitude's Analytics API, allowing developers to focus on implementing tracking logic rather than managing network requests or data formatting. The SDKs support client-side tracking for web and mobile applications, as well as server-side tracking for backend systems and data pipelines.

The official SDKs are maintained by Amplitude and are recommended for most integrations, offering consistent updates and direct support. Beyond official offerings, a community of developers has contributed additional libraries and integrations, extending Amplitude's reach to other languages and frameworks. These libraries typically wrap the core Amplitude HTTP API or build upon existing SDKs to provide platform-specific conveniences. The choice between an official SDK and a community library often depends on the specific project requirements, the target language, and the level of maintenance and support desired.

Amplitude's SDKs are engineered to handle various aspects of data collection, including:

  • Event Tracking: Capturing user actions, such as button clicks, page views, or feature usage, with associated properties.
  • User Identification: Associating events with specific users and managing user properties.
  • Session Management: Automatically tracking user sessions on client-side platforms.
  • Offline Tracking: Buffering events when an internet connection is unavailable and sending them once connectivity is restored.
  • Plugin Architecture: Allowing for custom modifications to event data before it is sent.

For detailed guidance on integrating any of these SDKs, developers can refer to the Amplitude Developer Documentation.

Official SDKs by language

Amplitude maintains official SDKs for a broad range of programming languages and platforms, ensuring robust and supported integrations for common development environments. These SDKs are actively developed and provide direct access to Amplitude's core tracking functionalities.

The following table outlines the key official SDKs, their typical package names, and installation methods:

Language/Platform Package/Module Name Installation Command Maturity/Status
JavaScript (Web) amplitude-js npm install amplitude-js Stable, Actively Maintained
Python amplitude-python pip install amplitude-python Stable, Actively Maintained
Ruby amplitude-api gem install amplitude-api Stable, Actively Maintained
Java amplitude-java Maven/Gradle dependency Stable, Actively Maintained
Go github.com/amplitude/amplitude-go go get github.com/amplitude/amplitude-go Stable, Actively Maintained
Swift (iOS/macOS) Amplitude-iOS CocoaPods/Swift Package Manager Stable, Actively Maintained
Kotlin (Android) amplitude-android Gradle dependency Stable, Actively Maintained
React Native @amplitude/react-native npm install @amplitude/react-native Stable, Actively Maintained
Flutter amplitude_flutter flutter pub add amplitude_flutter Stable, Actively Maintained
Unity Amplitude-Unity Unity Package Manager Stable, Actively Maintained
Xamarin Amplitude.Xamarin NuGet package Stable, Actively Maintained
R Ramplitude install.packages("Ramplitude") Stable, Actively Maintained
PHP amplitude/amplitude-php composer require amplitude/amplitude-php Stable, Actively Maintained
C# Amplitude.Net NuGet package Stable, Actively Maintained
Rust amplitude-rs cargo add amplitude-rs Stable, Actively Maintained

Each SDK provides specific documentation on its respective GitHub repository or within the Amplitude Developer Docs, detailing initialization, event tracking, user property management, and advanced configurations.

Installation

Installation methods vary by language and platform, leveraging standard package managers or direct integration methods. Below are common installation patterns for some primary SDKs.

JavaScript (Web)

For web applications, the Amplitude JavaScript SDK can be installed via npm or included directly via a CDN.

npm

npm install amplitude-js

CDN

<script type="text/javascript">
  (function(e,t){var n=e.amplitude||{_q:[],_iq:{}};function r(e,t){e.prototype[t]=function(){return this._q.push([t].concat(Array.prototype.slice.call(arguments,0))),this}}function i(e,t,n){return function(r){e._q.push([n,r].concat(Array.prototype.slice.call(arguments,1)))}},o=function(){return new i(n)},a=e.amplitude=n;n.is

Ensure to replace YOUR_API_KEY and YOUR_USER_ID placeholders with actual values from your Amplitude project settings, as described in the Amplitude JavaScript SDK installation guide.

Python

The Python SDK is typically installed using pip:

pip install amplitude-python

Further details on Python integration can be found in the Amplitude Python SDK documentation.

Java (Android/Backend)

For Java-based projects, including Android applications, the SDK is integrated via Maven or Gradle dependencies. For Android, add to your build.gradle file:

dependencies {
  implementation 'com.amplitude:amplitude-android:2.35.0'
}

Version numbers should be checked against the latest Amplitude Android SDK release.

Swift (iOS)

For iOS development, the Swift SDK can be added using CocoaPods or Swift Package Manager.

CocoaPods

pod 'Amplitude-iOS'

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/amplitude/Amplitude-iOS", from: "8.0.0")
]

Consult the Amplitude iOS SDK guide for comprehensive instructions.

Kotlin (Android)

For Kotlin-based Android projects, the installation is similar to Java, using Gradle:

dependencies {
  implementation 'com.amplitude:amplitude-android:2.35.0'
}

Refer to the Amplitude Android SDK documentation for the most current version and setup.

Quickstart example

After installation, the basic usage pattern across most Amplitude SDKs involves initializing the client, identifying the user, and tracking events. Here are quickstart examples for JavaScript and Python.

JavaScript (Web)

This example demonstrates initializing the Amplitude client, setting a user ID, and tracking a custom event on a web page.

<script type="text/javascript">
  amplitude.getInstance().init("YOUR_API_KEY");

  // Identify the user
  amplitude.getInstance().setUserId("user_123"); // Or use amplitude.getInstance().logRevenue() for revenue tracking
  amplitude.getInstance().setUserProperties({"cohort": "new_users", "plan": "premium"});

  // Track an event
  amplitude.getInstance().logEvent('Button Clicked', {"button_name": "buy_now", "page": "product_detail"});
</script>

Replace "YOUR_API_KEY" with your actual Amplitude project API Key. Further examples are available in the JavaScript SDK quickstart.

Python

This Python example shows how to initialize the Amplitude client in a server-side application, identify a user, and send an event.

import amplitude

# Initialize the Amplitude client
amplitude.init("YOUR_API_KEY")

# Identify the user
amplitude.set_user_id("user_456")
amplitude.set_user_properties({"country": "USA", "subscription_status": "active"})

# Track an event
amplitude.track('User Signed Up', {"signup_method": "email", "platform": "web"})

# (Optional) Flush events if not using a continuous process
# amplitude.flush()

Remember to replace "YOUR_API_KEY" with the appropriate key for your project. More detailed Python examples are provided in the Python SDK documentation.

For client-side applications, it is crucial to understand Cross-Origin Resource Sharing (CORS) implications when making API calls, which SDKs generally handle transparently. Server-side SDKs typically do not face CORS restrictions. The security of API keys should also be managed carefully; client-side keys are often public, while server-side keys should be kept confidential.

Community libraries

Beyond the official SDKs, the Amplitude developer community has contributed various libraries and integrations to support specific use cases, languages, or frameworks not covered by official offerings. These community-maintained resources can extend Amplitude's capabilities but may have varying levels of support and maintenance compared to official SDKs.

Examples of community contributions often include:

  • Framework-specific wrappers: Libraries that integrate Amplitude tracking more idiomatically into frameworks like Vue.js or Angular, building on top of the official JavaScript SDK.
  • Language bindings: SDKs for less common programming languages or niche environments.
  • Data pipeline integrations: Tools for ingesting data from specific databases, message queues, or other analytics platforms into Amplitude.
  • Testing utilities: Libraries that assist in testing Amplitude integrations or mocking Amplitude calls during development.

While official documentation is the primary source for Amplitude-supported integrations, platforms like GitHub are common repositories for community-developed libraries. Developers interested in exploring community options should evaluate the library's active maintenance, community support, and alignment with their project's requirements. Links to specific community libraries are often found in forum discussions or developer blogs, rather than a centralized Amplitude-maintained list.