kochava.logCustomEvent()

Type Function
Return value none
Revision 2017.3060
Keywords analytics, attribution, Kochava, logCustomEvent
See also kochava.logStandardEvent()
kochava.logDeeplinkEvent()
kochava.*

Overview

Sends a custom event to Kochava.

Important

This function replaces the previous kochava.logEvent() function. For backward compatibility, logEvent() will continue to work, however we recommend that you update your code to use this logCustomEvent() instead. Essentially, logEvent() has been deprecated and it will be removed in a future plugin update.

Syntax

kochava.logCustomEvent( eventName [, eventValue, receipt, googleDataSignature] )
eventName (required)

String. The name of the event. Note that event names cannot start with an underscore (_).

eventValue (optional)

String. An optional event value — see the next section for details.

receipt (optional)

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

googleDataSignature (optional)

String. This parameter is mandatory when logging a Google IAP receipt. It expects the data from event.transaction.signature found in the in-app purchase transaction callback.

Event Value

The optional eventValue parameter may be used for any of the following:

If the string passed in eventValue is all numeric, potentially including a decimal point, Kochava will automatically sum the amounts passed in eventValue for the associated eventName. For example, if you send the purchase amount of in-app purchases in eventValue and set eventName as IAP: Purchase Price, Kochava will add up all the purchase amounts and present them as a total for IAP: Purchase Price.

Regardless of what is passed in eventValue, Kochava's user dashboard will let you access all of the data passed in eventValue for any eventName and present a count of all the times kochava.logCustomEvent() passed it.

When logging an app store receipt via eventValue, it's recommended that you provide a table with the following properties, formatted as a JSON string:

local eventValuePayload = json.encode(
    {
        customer_id = "internalCustomerId",
        sum = 0.99,
        currency = "jpy",
        items_in_basket = 1,
        checkout_as_guest = false
    }
)
logCustomEvent( "bonusPackPurchase", eventValuePayload, event.transaction.receipt )

Example

local kochava = require( "plugin.kochava" )

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

-- Initialize plugin
kochava.init( kochavaListener,
    {
        appGUID = "YOUR_APP_GUID"
    }
)

kochava.logCustomEvent( "CUSTOM_EVENT", "CUSTOM_EVENT_VALUE" )