tenjin.logPurchase()

Type Function
Return value none
Revision 2017.3060
Keywords analytics, attribution, Tenjin, logPurchase
See also tenjin.init()
tenjin.logEvent()
tenjin.*

Overview

Sends an IAP purchase event to Tenjin.

Syntax

tenjin.logPurchase( purchaseData [, purchaseReceipt] )
purchaseData (required)

Table. Table containing IAP purchase data — see the next section for details.

purchaseReceipt (optional)

Table. An optional table containing Apple App Store or Google Play receipt data — see the next section for details.

Parameter Reference

The purchaseData table includes parameters for logging IAP purchases.

productId (required)

String. The product ID/name for the IAP purchase.

currencyCode (required)

String. The currency of the IAP transaction.

quantity (required)

Number. The number of units bought.

unitPrice (required)

Number. The unit price of the IAP item.

The purchaseReceipt table includes parameters for logging IAP receipts.

receipt (required)

String. This parameter is an in-app purchase receipt. It expects the data from event.transaction.receipt found in the in-app purchase transaction callback. Supported markets include Apple IAP and Google IAP.

signature (required)

String. 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.

transactionId (required)

String. 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.

Example

local tenjin = require( "plugin.tenjin" )

local function tenjinListener( event )
    -- Handle events here
end

-- Initialize plugin
tenjin.init( tenjinListener, { apiKey="YOUR_API_KEY" } )

-- Sometime later, log an IAP purchase
tenjin.logPurchase( 
    { 
        productId = "Bonus Pack",
        currencyCode = "USD",
        quantity = 1,
        unitPrice = 0.99
    }
)