Purchase Analytics
The in-app purchase service reports every purchase to analytics on its own, including the ones that end without a sale: a cancel, a declined payment, a store that could not be reached. You do not need to log anything for a purchase.
Events
| Event | Sent when |
|---|---|
purchaseStarted | Purchase() is called, before the store is asked. |
purchaseSucceeded | The store confirmed a purchase the game is waiting for. |
purchaseFailed | The purchase answered Failed or StoreUnavailable. |
purchaseCancelled | The purchase answered Cancelled. |
purchaseDeferred | A paid purchase arrived through PurchaseRecovered. |
unvalidatedTransaction | The store confirmed a purchase, either in a purchase call or as a recovered purchase. This is the record the server validates for revenue. |
A purchase that answers AnotherPurchaseInProgress sends no event, because the purchase never started.
Linking purchase events to your own events
Every event except purchaseDeferred carries the purchase’s session id and the economyChangeId you passed to Purchase(). The session id is the SessionId on the purchase result, so you can match any of your own events to the purchase events:
var economyChangeId = "shop-" + Guid.NewGuid().ToString("N");var result = await inAppPurchases.Purchase(product, economyChangeId);
// result.SessionId and economyChangeId are on every event about this purchase.On a recovered purchase, both ids are empty when the SDK could not identify the purchase call that started it.