With Segment, you can manage data and integrations with services across your Growth, Product, and Marketing stack. By tracking events and users via Segment's API and libraries, you can send your product's data to all your analytics and marketing platforms, with minimal instrumentation. They offer support for most platforms, including iOS, Android, JavaScript, Node.js, PHP, and more.
This guide complements Segment's Amplitude (Actions) documentation. It provides more details on how they affect your data in Amplitude, and instructions for setting up the integrations.
Segment has an old destination, Segment's Amplitude (Classic). Future updates are limited to security updates and bug fixes. This document is mainly focused on the new destination, Segment's Amplitude (Actions).
To send data to Amplitude, you can:
Follow these steps with your Amplitude API key.
To ensure that Segment can send data to Amplitude, make sure your Segment's Amplitude destination is connected to one of your Segment sources:
Send data to your Segment source, and validate your events in Amplitude.
In addition to Segment's libraries, you can install Amplitude's SDKs. If you do, Segment's library delegates the data collection to Amplitude's SDK, which then sends the data to Amplitude's servers.
There are advantages and disadvantages to taking the client-side bundled approach. One advantage is that adding Amplitude native SDKs adds session tracking capability and automatic user property tracking:
Start Session
and End Session
events to mark the start and end of a user's mobile session.Keep in mind that adding more SDKs increases the size of your application (each one is <200kb). You may have to account for this if you are already using several libraries in your app. These SDKs are optional, and you can still conduct almost the same analysis in Amplitude by using only Segment's libraries.
Without session tracking:
Without Amplitude's SDKs, you have to map user properties such as device type and operating system manually to track them, as described in Segment's docs.
Set up a Segment Source to send data to Segment.
Follow Segment's Analytics.js quickstart guide and paste the snippet onto your website. Don't forget to put your Segment write key in the snippet.
You are now ready to use track
and identify
to track users. Analytics.js also automatically installs Amplitude's JavaScript SDK onto your website, so you can access the JavaScript SDK directly.
There are settings for the JavaScript integration you can configure in the Advanced Settings of your Segment Amplitude integration panel, without needing to change your instrumentation:
page
generates Viewed ___ Page
events. If you select more than one of these three options at a time, a single page
call generates multiple events.If you send screen
calls to Amplitude, review these destination settings.
Follow Segment's iOS quickstart guide. Install the Analytics pod using CocoaPods, import the SEGAnalytics.h
header file, and initialize Segment's library in your iOS app.
At this point, you can start calling track
and identify
to track users in your app. You also have the option to install Amplitude's iOS SDK alongside Segment's library to supplement with more tracking capabilities. The pros and cons of adding Amplitude's SDK are explained Client-side bundled integration. If you choose to add the Amplitude SDK, follow these steps:
Install a second pod 'Segment-Amplitude' in CocoaPods:
pod 'Segment-Amplitude'
If you are using Objective-C, then add this second header in the file where you initialized the Segment SDK:
#import <Segment-Amplitude/SEGAmplitudeIntegrationFactory.h>
If you are using Swift and have use_frameworks!
set, then add this second header in the file where you initialized the Segment SDK:
#import <Segment\_Amplitude/SEGAmplitudeIntegrationFactory.h>
Register Amplitude's SDK with Segment's SDK (do this before you initialize Segment's SDK):
1[configuration use:[SEGAmplitudeIntegrationFactory instance]];2[SEGAnalytics setupWithConfiguration:configuration];
For examples of how your code should look, see the Segment iOS demo code.
If you send screen
calls to Amplitude, review these destination settings.
Follow Segment's Android quickstart guide. Install Segment's library using Gradle and initialize the Analytics client in your Android app. You may also need to update your app's permissions in the Android manifest file.
At this point, you can start calling track
and identify
to track users in your app. You also have the option to install Amplitude's Android SDK alongside Segment's library to supplement with more tracking functionality. The pros and cons of adding Amplitude's SDK are explained Client-side bundled integration. If you choose to add the Amplitude SDK, follow these steps:
Add the following to your build.gradle
file:
compile 'com.segment.analytics.android.integrations:amplitude:+'
In the file where you initialize the Segment SDK add:
import com.segment.analytics.android.integrations.amplitude.AmplitudeIntegration;
Register the Amplitude integration with Segment's SDK. When building the Analytics object, append .use(AmplitudeIntegration.FACTORY)
before the .build()
. It would look something like this:
1Analytics analytics = new Analytics.Builder(this,"KEY").use2(AmplitudeIntegration.FACTORY).build();3Analytics.setSingletonInstance(analytics);
For examples of how your code should look, see the Android demo code.
Follow the appropriate instructions in Segment's documentation.
Segment and Amplitude use slightly different terms to describe the same concepts. The following table shows the mapping between the two:
Segment | Amplitude | Description |
---|---|---|
track (with properties) |
track (with properties) |
Logs an event with the specified event properties. |
track with property "revenue" | revenue |
Logs a revenue event to record a revenue amount. |
identify with traits |
setUserId , identify |
Assigns a userId and set any traits as user properties. |
screen / page with name |
track "Viewed" + name |
Logs an event "Viewed [page]" where [page] is the name provided. |
alias |
User Mapping (Aliasing) | UserId aliasing lets you merge two users together that would otherwise have different User IDs tracked in Amplitude. |
group |
groupIdentify (with GroupName) |
Lets you designate user groups. |
For more information, see the Segment documentation.
Amplitude Audiences lets you automatically send behavioral audiences to ad networks, marketing automation tools, and personalization engines so you can better tailor campaigns and product experiences.
See Send Cohorts to Segment for more information.
Contact Segment support (friends@segment.com) or Amplitude support.
Thanks for your feedback!
April 22nd, 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.