This page helps you to understand the types of events and how to send events to Contlo.
Analyzing events helps in understanding how users interact with an application. There are three types of app events in the Contlo SDK:
System events
These events are fired automatically by the SDK.
- App launched: This event is fired when the app is launched from the background or killed state.
- App installed: This event is fired when a user installs or reinstalls the app, or clears app data, and launches it for the first time.
- App backgrounded: This event is fired when the app is sent into the background state.
- App updated: This event is fired when a user opens the app for the first time after updating.
Send system events to Contlo
To start sending system events to Contlo, follow the steps below:
- Navigate to the Android directory, open root-level build.gradle file and add the following code:
allprojects {
repositories {
maven {
url 'https://nexus.contlo.com/repository/contlo-android-sdk' }
}
}
- Go to your App directory, open the module build.gradle file and add the following dependency:
dependencies {
implementation 'com.contlo:android-core:1.0.0'
}
- Open the main application file that represents the start of the application and import the following Conlto packages:
import com.contlo.core.lifecycle.ContloSDKLifecycleCallbacks
import com.contlo.core.main.Contlo
- To listen to the system events:
- Initialize the SDK using
init()
method with the following parameters:- Context: Pass the application context as this keyword.
- API key: Pass the API key (created from the Contlo dashboard).
Use the same API key that is used to initialize the React Native SDK.
- Add the
registerActivityLifecycleCallbacks()
method to listen to the system events.
- Initialize the SDK using
import android.app.Application
import com.contlo.androidsdk.main.Contlo
import com.contlo.androidsdk.lifecycle.ContloSDKLifecycleCallbacks // import lifcycle callbacks
class ContloApplication : Application() {
override fun onCreate() {
super.onCreate()
Contlo.init(this, "<API_KEY>")
registerActivityLifecycleCallbacks(ContloSDKLifecycleCallbacks(applicationContext))
}
}
Message events
These events are related to push notifications that are automatically sent to Contlo.
- Mobile push received: This event is fired when the SDK receives the notification payload from Contlo.
- Mobile push clicked: This event is fired when the user clicks the notification.
- Mobile push dismissed - This event is fired when the user dismisses the notification or clicks the Clear all notifications button.
Custom Events
These events are your user journey events that you would track across the user journey. You can send these custom events to Contlo using the sendEvent()
method. Refer to the code below:
Contlo.sendEvent("<event-name>")
You can send additional parameters in the sendEvent()
method. Refer to the examples below:
Example 1: You can send events with custom properties. Refer to the code given below:
Contlo.sendEvent({
"event": eventName,
"eventProperty": {
"extraKey": "extraValue"
}
})
Example 2: You can also send profile properties to Contlo:
Contlo.sendEvent({
"event": eventName,
"eventProperty": {
"extraKey": "extraValue"
},
"profileProperty": {
"firstName": "Contlo"
}
})