Type Function Return value none Revision Release 2024.3703 Keywords analytics, attribution, AppsFlyer, logPurchase See also appsflyer.getVersion() appsflyer.*
AppsFlyer’s SDK provides server verification for in-app purchases. This method automatically generates an af_purchase
in-app event.
For a list of possible return values for validating receipts, please refer to Apple's documentation here.
appsflyer.logPurchase( productData )
Table. Table containing key-value parameters. In-App Events provide insights on what is happening in your app. It is recommended to take the time and define the events you want to measure to allow you to track ROI (Return on Investment) and LTV (Lifetime Value).
You may specify your own custom key-value parameters (optional). Values should be of type String
.
The productData
table for iOS includes following parameters for logging IAP purchases:
String. The product ID/name for the IAP purchase.
String. The currency of the IAP transaction.
String. The transaction ID. This parameter applies to Apple App Store transactions only and is mandatory when logging an Apple IAP receipt. It expects the data from event.transaction.identifier found in the in-app purchase transaction callback.
String. The unit price of the IAP item. The price
parameter should contain the total revenue associated to the validated purchase event.
Table. Table containing additional key-value parameters.
The productData
table for Android includes following parameters for logging IAP purchases:
String. API Key, the developer gets this from the Google portal.
String. The transaction signature. The developer gets it from google api when purchase succeeded. This parameter applies to Google Play transactions only and is mandatory when logging a Google IAP receipt. It expects the data from event.transaction.signature found in the in-app purchase transaction callback.
String. Purchase data is the actual product purchased in json format. The developer gets it from google api when purchase succeeded.
String. The unit price of the IAP item. The price
parameter should contain the total revenue associated to the validated purchase event.
String. The currency of the IAP transaction.
Table. Table containing additional key-value parameters.
local appsflyer = require( "plugin.appsflyer" ) local function appsflyerListener( event ) -- Handle events here end -- Initialize plugin appsflyer.init( appsflyerListener, { appID = "YOUR_APP_ID", devKey = "YOUR_DEV_KEY" } ) appsflyer.logPurchase( { productId = "111", price = "100", currency = "USD", transactionId = "222", parameters = { first = "1", second = "2" } } )
local appsflyer = require( "plugin.appsflyer" ) local function appsflyerListener( event ) -- Handle events here end -- Initialize plugin appsflyer.init( appsflyerListener, { appID = "YOUR_APP_ID", devKey = "YOUR_DEV_KEY" } ) appsflyer.logPurchase( { publicKey = "111", signature = "222", purchaseData = "333", price = "100", currency = "USD", parameters = { first = "1", second = "2" } } )