AppMetrica
AppMetrica is a no-cost tool that helps you track advertisements and analyze how your mobile app is doing. It works in real-time, so you see things right away.
How to set up AppMetrica integration
To integrate AppMetrica go to Integrations > AppMetrica and set credentials.
Open AppMetrica apps list. Choose the app you want to send events to and go to Settings. Copy Application ID and Post API key and use them to set up the integration in Adapty.
AppMetrica syncs events every 4 hours, so it may take some time for events to appear in the dashboard. AppMetrica doesn't support sending events revenue, but we send it as regular property.
Events and tags
Below the credentials, there are three groups of events you can send to AppMetrics from Adapty. Simply turn on the ones you need. Check the full list of the events offered by Adapty here.
We recommend using the default event names provided by Adapty. But you can change the event names based on your needs.
SDK configuration
Use the Adapty.updateProfile()
method to set the appmetricaProfileId
or appmetricaDeviceId
parameter. Setting appmetricaDeviceId
is preferred!
If these aren’t set, Adapty will default to using your user ID (customerUserId
). Make sure the user ID you use to send data to AppMetrica from your app matches the one you send to Adapty. These links can help you set up a user ID for AppMetrica in your app.
- Set profile ID iOS;
- Get device ID iOS;
- Set profile id Android;
- Get device ID Android.
- iOS (Swift)
- Android (Kotlin)
- Flutter (Dart)
- Unity (C#)
- React Native (TS)
import AppMetricaCore
if let deviceID = AppMetrica.deviceID {
let builder = AdaptyProfileParameters.Builder()
.with(appmetricaDeviceId: deviceID)
.with(appmetricaProfileId: "YOUR_ADAPTY_CUSTOMER_USER_ID")
Adapty.updateProfile(params: builder.build())
}
val startupParamsCallback = object: StartupParamsCallback {
override fun onReceive(result: StartupParamsCallback.Result?) {
val deviceId = result?.deviceId ?: return
val params = AdaptyProfileParameters.Builder()
.withAppmetricaDeviceId(deviceId)
.withAppmetricaProfileId("YOUR_ADAPTY_CUSTOMER_USER_ID")
.build()
Adapty.updateProfile(params) { error ->
if (error != null) {
// handle the error
}
}
}
override fun onRequestError(
reason: StartupParamsCallback.Reason,
result: StartupParamsCallback.Result?
) {
//handle error
}
}
AppMetrica.requestStartupParams(context, startupParamsCallback, listOf(StartupParamsCallback.APPMETRICA_DEVICE_ID))
import 'package:appmetrica_plugin/appmetrica_plugin.dart';
final deviceId = await AppMetrica.deviceId;
if (deviceId != null) {
final builder = AdaptyProfileParametersBuilder()
..setAppmetricaDeviceId(deviceId)
..setAppmetricaProfileId("YOUR_ADAPTY_CUSTOMER_USER_ID");
try {
await adapty.updateProfile(builder.build());
} on AdaptyError catch (adaptyError) {
// handle error
} catch (e) {}
}
var deviceId = AppMetrica.GetDeviceId();
if (deviceId != null {
var builder = new Adapty.ProfileParameters.Builder();
builder.SetAppmetricaProfileId("YOUR_ADAPTY_CUSTOMER_USER_ID");
builder.SetAppmetricaDeviceId(deviceId);
Adapty.UpdateProfile(builder.Build(), (error) => {
// handle error
});
}
import { adapty } from 'react-native-adapty';
import AppMetrica, { DEVICE_ID_KEY, StartupParams, StartupParamsReason } from '@appmetrica/react-native-analytics';
// ...
const startupParamsCallback = async (
params?: StartupParams,
reason?: StartupParamsReason
) => {
const deviceId = params?.deviceId
if (deviceId) {
try {
await adapty.updateProfile({
appmetricaProfileId: 'YOUR_ADAPTY_CUSTOMER_USER_ID',
appmetricaDeviceId: deviceId,
});
} catch (error) {
// handle `AdaptyError`
}
}
}
AppMetrica.requestStartupParams(startupParamsCallback, [DEVICE_ID_KEY])