Skip to main content
The Facebook SDK integrates with StoreKit to automatically detect and log in-app purchase events. No extra code is required once the SDK is initialised.

What is automatically tracked

The SDK’s payment observer (FBSDKPaymentObserver) monitors the StoreKit transaction queue and logs events when purchases complete:
ScenarioEvent logged
Successful purchase (consumable or non-consumable)fb_mobile_purchase
Failed purchasefb_mobile_purchase_failed
Restored purchasefb_mobile_purchase_restored
Subscription initiated checkoutSubscriptionInitiatedCheckout
Subscription failedSubscriptionFailed
Subscription restoredSubscriptionRestore
Each purchase event includes parameters such as:
ParameterRaw key
Product typefb_iap_product_type
Transaction IDfb_transaction_id
Transaction datefb_transaction_date
Subscription periodfb_iap_subs_period
Whether it is a start trialfb_iap_is_start_trial
Whether it has a free trialfb_iap_has_free_trial
Trial periodfb_iap_trial_period
Trial pricefb_iap_trial_price
Currencyfb_currency

StoreKit Original API

Automatic tracking uses SKPaymentQueue to observe completed, failed, and restored transactions. It activates when FacebookAutoLogAppEventsEnabled is true (the default) in your Info.plist.

StoreKit 2

On iOS 15 and later, the SDK also listens for new transactions via the async Transaction.updates sequence, which covers StoreKit 2 purchases. This happens automatically when the app becomes active.
// The SDK calls this internally — you do not need to add this yourself:
// Task { await IAPTransactionObserver.shared.observeNewTransactions() }
StoreKit 2 automatic tracking requires iOS 15.0 or later. On earlier OS versions the SDK falls back to the Original API observer.

Disabling automatic IAP tracking

To opt out of automatic purchase tracking, set FacebookAutoLogAppEventsEnabled to false in your Info.plist:
<key>FacebookAutoLogAppEventsEnabled</key>
<false/>
When auto-logging is off, you must log purchases manually if you still want purchase data in Events Manager.

Manual purchase logging

If you have disabled auto-logging or need to supplement automatic events, use the logPurchase method:
import FacebookCore

// After a successful StoreKit transaction:
AppEvents.shared.logPurchase(
    purchaseAmount: Double(truncating: product.price),
    currency: product.priceLocale.currencyCode ?? "USD",
    parameters: [
        .init(FBSDKAppEventParameterNameTransactionID): transaction.transactionIdentifier ?? ""
    ]
)

App Store data disclosure

Apple requires that you disclose the data types your app collects in its App Store privacy nutrition label. When using automatic IAP tracking, you must declare Purchase History as a data type collected for third-party advertising purposes.
Review the App Store data collection requirements and update your app’s privacy nutrition label accordingly before submitting.

Build docs developers (and LLMs) love