kochava.logEvent()

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

Overview

Sends an event to Kochava.

Important

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

Syntax

kochava.logEvent( 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.logEvent() 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,
        items_in_basket = 1,
        checkout_as_guest = false
    }
)
logEvent( "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.logEvent( "CUSTOM_EVENT", "CUSTOM_EVENT_VALUE" )