Measure in-app purchases

In-app purchases (IAP) are digital content or features that you can sell in a mobile app through Google Play or the Apple App Store so your app doesn't have to process financial transactions. Examples of in-app purchases include subscription-based content or special game pieces.

Analytics shows IAP events in the In-app purchases report.

For Android apps, the Analytics SDK integrates with Google Play. For Apple platform apps, the SDK integrates with the Apple App Store using the StoreKit 1 and StoreKit 2 APIs from Apple.

In most cases, the Analytics SDK automatically collects IAP events without requiring API calls in your app. This guide explains how to set up your project for automatic tracking, and it describes some special cases that require a few lines of code to implement.

Before you begin

If you're developing an Android app, you can measure IAP events as soon as you link to Google Play. The remainder of this guide is focused on Apple platform apps.

If you're an Apple developer, make sure you're familiar with the Apple StoreKit 1 and StoreKit 2 in-app purchase APIs by reviewing the Apple documentation.



If you're using StoreKit 1, the Analytics SDK automatically logs IAP events.

If you're using StoreKit 2, use the following code to log IAP events.

import StoreKit
import FirebaseAnalytics

// A user tapped a button to purchase an item.
func userTappedPurchaseUpgradeButton() {
  let product = ...

func purchaseSomeProduct(_ product: Product) {
  // Purchase a Product. This is mostly standard boilerplate StoreKit 2
  // code, except for the Analytics.logTransaction() call.
  let result = try await product.purchase()
  switch result {
  case .success(let verification):
      let transaction = try checkVerified(verification)

      // Call this Firebase API to log the in-app purchase event.

      await transaction.finish()


If you're using StoreKit 1, the Analytics SDK automatically logs IAP events.

StoreKit 2 is Swift-only, so an Objective-C implementation is not supported.


To log IAP events, link to Google Play.


To log IAP events, link to Google Play.