Guides
GuidesLog In
Guides

Amplitude

This guide describes how to add and configure Amplitude integration.

Amplitude is a powerful mobile analytics service. Send events to Amplitude via Apphud, analyze your users behavior and make necessary decisions.

How to Add Integration?

Step 1

  • Integrate Apphud SDK.
  • Integrate Amplitude SDK.
  • Match User IDs between Apphud and Amplitude. If you set your custom User ID keep in mind that Amplitude requires user id to be minimum 5 characters.

Step 2

At Apphud go to "Integrations" section and add Amplitude:

Step 3

Enter Amplitude API Key at the "Amplitude production app API Key" field:

2778

Step 4

You may have one more app created in Amplitude used for testing purposes not to mix test and live data. If you have such app you can paste it's Amplitude API Key into "Amplitude test app API key" field.

Step 5

You can enter your custom event names or disable some:

2778

Step 6

Enable integration and Save:

2778

Match User IDs

Here is an example of initialising both SDKs with User IDs matching.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

    Apphud.start(apiKey: "YOUR_API_KEY")
    Apphud.setDelegate(self)
    
    Amplitude.instance()?.initializeApiKey("AMPLITUDE_API_KEY", userId: Apphud.userID())

    return true
}

func apphudDidChangeUserID(_ userID: String) {
    // Match again
    Amplitude.instance()?.setUserId(userID)
}
[Apphud startWithApiKey: @"API_KEY"];
[[Amplitude] instance] initializeApiKey:@"API_KEY" userId:[Apphud userID]];
Apphud.start(apiKey: "YOUR_API_KEY")
Amplitude.getInstance().initialize(this, "AMPLITUDE_API_KEY", Apphud.userID());
Future<void> _initAmplitude() async {
    final analytics = Amplitude.getInstance(instanceName: 'project');
    final userId = await Apphud.userID();
    await analytics.init('API_key', userId: userId);
  }

@override
  Future<void> apphudDidChangeUserID(String userId) async {
    printAsJson('ApphudListener.apphudDidChangeUserID', userId);

    final analytics = Amplitude.getInstance(instanceName: 'project');
    final userId = await Apphud.userID();
    await analytics.setUserId(userId);
  }

Events Cheat Sheet

Here is example of some events and their parameters that are being sent to Amplitude.

πŸ“˜

Note

You can read more about subscription events here and about parameters here.

Trial

Trial period started

Default event name: [Apphud] trial_started

Parameters:

  • product_id: String
  • unit: String
  • units_count: Integer

Successful conversion from trial period to regular subscription

Default event name: [Apphud] trial_converted

Parameters:

  • product_id: String
  • local_price: Float
  • currency: String
  • usd_price: Float

Cancellations

Trial Canceled

Default event name: [Apphud] trial_canceled

Parameters:

  • product_id: String

Subscription Canceled

Default event name: [Apphud] subscription_canceled

Parameters:

  • product_id: String

Regular

Subscription started

Default event name: [Apphud] subscription_started

Parameters:

  • product_id: String
  • local_price: Float
  • currency: String
  • usd_price: Float

Subscription renewed

Default event name: [Apphud] subscription_renewed

Parameters:

  • product_id: String
  • local_price: Float
  • currency: String
  • usd_price: Float

Subscription refunded

Default event name: [Apphud] subscription_refunded

Parameters:

  • product_id: String
  • local_price: Float
  • currency: String
  • usd_price: Float
  • reason: String

Other Events

Non renewing purchase

Default event name: [Apphud] non_renewing_purchase

Parameters:

  • product_id: String
  • local_price: Float
  • currency: String
  • usd_price: Float

πŸ“˜

Important Note

You can also choose between sending revenue as sales or proceeds (without Apple or Google 15%-30% commission).

Detailed log of each event is available in theEvents tab.

User Properties

In the table below you can see the list of user properties that are sent to Amplitude.

πŸ“˜

Note

More information about user properties can be found here.

ParameterType
[Apphud] status-group_nameString
[Apphud] autorenew-group_nameBoolean
[Apphud] total_spentFloat
[Apphud] payingBoolean
[Apphud] payments_countInteger

Sending Test Event

You may send test event to Amplitude to check if integration is set up correctly. Click "…" and click on "Send test event":

You will see new user under "User Look-Up" report: