Guides
Plan-enterprise-icon
Expo Application Services
API Reference

Amplitude


Info-icon

Deprecated. This module will be removed in SDK 46. There will be no replacement that works with the classic build service (expo build) because the classic build service has been superseded by EAS Build. With EAS Build and development builds, you should use the official @amplitude/react-native instead.

expo-analytics-amplitude provides access to Amplitude mobile analytics which allows you track and log various events and data. This module wraps Amplitude's iOS and Android SDKs. For a great example of usage, see the Expo app source code.

Please note: Session tracking may not work correctly when running Experiences in the main Expo app. It will work correctly if you create a standalone app. For example, the version logged when running experiences in the Expo app will be the Expo app version. Whereas in standalone apps, the version set in app.json is used. For more information see this issue on GitHub.

Platform Compatibility

Android DeviceAndroid EmulatoriOS DeviceiOS SimulatorWeb
Status-success-iconStatus-success-iconStatus-success-iconStatus-success-iconStatus-failed-icon

Installation

Terminal
expo install expo-analytics-amplitude

If you're installing this in a bare React Native app, you should also follow these additional installation instructions.

API

import * as Amplitude from 'expo-analytics-amplitude';

Methods

Amplitude.clearUserPropertiesAsync()

Clear properties set by setUserPropertiesAsync().

  • Undo-iconPromise<void>

Amplitude.initializeAsync(apiKey)

NameTypeDescription
apiKeystring

Your Amplitude application's API key.


Initializes Amplitude with your Amplitude API key. If you're having trouble finding your API key, see step 4 of these instructions.


Amplitude.logEventAsync(eventName)

NameTypeDescription
eventNamestring

The event name.


Log an event to Amplitude. For more information about what kind of events to track, see here.


Amplitude.logEventWithPropertiesAsync(eventName, properties)

NameTypeDescription
eventNamestring

The event name.

propertiesRecord<string, any>

A map of custom properties.


Log an event to Amplitude with custom properties. For more information about what kind of events to track, see here.


Amplitude.setGroupAsync(groupType, groupNames)

NameTypeDescription
groupTypestring

The group name, e.g. "sports".

groupNamesstring[]

An array of group names, e.g. ["tennis", "soccer"].

Info-icon

Note: The iOS and Android Amplitude SDKs allow you to use a string or an array of strings. We only support an array of strings. Just use an array with one element if you only want one group name.


Add the current user to a group. For more information, see here for iOS and see here for Android.


Amplitude.setTrackingOptionsAsync(options)

NameTypeDescription
optionsAmplitudeTrackingOptions

Options object for what should not be tracked. The table below describes what properties the object may contain. All properties are expected to be booleans. For example, passing disableCarrier: true disables tracking the device's carrier.


By default, the Amplitude SDK will track several user properties such as carrier and city. You can use this method to customize and disable individual fields.

Info-icon

Note: These configurations will prevent default properties from being tracked on newly created projects, where data has not yet been sent. Please contact platform@amplitude.com if you would like default properties blocked (moving forward) on projects with existing data.


Amplitude.setUserIdAsync(userId)

NameTypeDescription
userIdnull | string

User ID for the current user. Can be set to null (e.g. when the user is logging out).


Assign a user ID to the current user. If you don't have a system for user IDs you don't need to call this. See this page for details.


Amplitude.setUserPropertiesAsync(userProperties)

NameTypeDescription
userPropertiesRecord<string, any>

A map of custom properties.


Set properties for the current user. See here for details.


Interfaces

AmplitudeTrackingOptions

NameTypeDescription
disableAdid
(optional)
boolean-
disableCarrier
(optional)
boolean

Disable tracking of the device's carrier.

disableCity
(optional)
boolean

Disable tracking of the user's city.

disableCountry
(optional)
boolean

Disable tracking of the user's country.

disableDMA
(optional)
boolean

Disable tracking of the user's DMA.

disableDeviceBrand
(optional)
boolean

Disable tracking of the device brand.

disableDeviceManufacturer
(optional)
boolean

Disable tracking of the device manufacturer.

disableDeviceModel
(optional)
boolean

Disable tracking of the device model.

disableIDFV
(optional)
boolean

Disable tracking of the user's IDFV.

disableIPAddress
(optional)
boolean

Disable tracking of the user's IP address.

disableLanguage
(optional)
boolean

Disable tracking of the device's language.

disableLatLng
(optional)
boolean

Disable tracking of the user's current latitude and longitude coordinates.

disableOSName
(optional)
boolean

Disable tracking of the device's OS name.

disableOSVersion
(optional)
boolean

Disable tracking of the device's OS version.

disablePlatform
(optional)
boolean

Disable tracking of the device's platform.

disableRegion
(optional)
boolean

Disable tracking of the user's region.

disableVersionName
(optional)
boolean

Disable tracking of the app version the user is on for your app.


  • Message-iconAsk a question on the forums about Amplitude
  • Github-iconView open bug reports for Amplitude
  • Code-iconView source code for Amplitude
  • Build-iconView package in npm Registry
  • Edit-iconEdit this page

Was this doc helpful?