In-app Events
Events help you to track all the user actions within your app. For example, sign up, purchase made, feedback given and so on. Events analytics and the associated data helps you understand your users.
Event types
Zoho Apptics provides two types of event analytics; Defined events and Custom events.
Defined events - These are the default events that are available for your use once you have integrated our SDK.
Custom events - These are the events that you want to capture using our SDK.
To be able to use either the defined or custom events, you need to:
- Make sure that you have integrated Apptics with your app, refer to the integration guide for detailed steps.
Add the SDK to your app
- Declare analytics dependency using Apptics BoM.
Copieddependencies {
// ...
// Apptics BoM, latest version is mentioned in the integration guide.
implementation platform('com.zoho.apptics:apptics-bom:[latest-version]')
// Since BoM version is specified, no need to explicitly specify the dependency version.
implementation 'com.zoho.apptics:apptics-analytics'
}
- Alternatively, if you do not use the Apptics BoM, you can directly declare the analytics dependency with its version.
Copieddependencies {
// Have to explicitly mention the version, if you are not using BoM.
// latest version is mentioned in the integration guide.
implementation 'com.zoho.apptics:apptics-analytics:[latest-version]'
}
Note: It is recommend to use Apptics BOM to avoid unnecessary compatibility issues.
- Initialize analytics in application onCreate() method.
CopiedApptics.init(this)
Logging custom events
Use AppticsEvents.addEvent() method to log the custom events, event groups, and custom properties. Event name and event group name are mandatory to be added and cannot be null or empty.
CopiedAppticsEvents.addEvent("event_name", "group_name")
Make sure that event name and group name follow the below norms, else the event won't be logged within the SDK.
- should not be more than 100 characters.
- should start with an alphabet.
- should not contain any space or special characters apart from underscore (_).
- cannot start with 'ap_' or 'AP_'. These are reserved for the defined events.
An example of a valid event name : 'helloworld' , 'Hello_world' , 'helloWorld'
An example of an invalid event name : '_helloworld' , '1hello' , `Hello World` , 'ap_helloworld`
Custom events with properties
Event properties are any additional information that can be associated with the events you are capturing using our SDK. These properties are can be passed as a JSONObject or a HashMap<String,Any>.
Sample snippet to use properties as a JSONObject.
Copiedval prop = JSONObject().apply {
put("item", "Box")
put("quantity", 10)
}
AppticsEvents.addEvent("event_name", "group_name", prop)
Sample snippet to use properties as a HashMap.
Copiedval prop = HashMap<String, Any>().apply {
put("item", "Box")
put("quantity", 10)
}
AppticsEvents.addEvent("event_name", "group_name", prop)
Make sure that the event properties follow the below norms else, the properties won't be logged with the events.
- property key should not be more than 50 characters.
- property key should start with an alphabet.
- property key should not contain any space or special characters except underscore (_).
- property key should not start with 'ap_' or 'AP_'.
- property value can be a number (init, float, double, long), boolean, or string. Other data types such as JSONObject or JSONArray will be converted to string.
- property value length should not be more than 250 characters.
Logging defined events
Our SDK comes with a set of default events known as defined, available for your use once you have completed the SDK integration. These events are not tracked automatically.
com.zoho.apptics.analytics.DefinedEvents is the endpoint for all the DefinedEvents.
You can use AppticsEvents.addEvent() method to track these defined events. Here is a list of all the available defined events
Group Name | Event Name |
---|---|
AP_APP_LIFE_CYCLE | AP_APP_INSTALL |
AP_APP_LIFE_CYCLE | AP_APP_UNINSTALL |
AP_APP_LIFE_CYCLE | AP_APP_UPDATE |
AP_APP_LIFE_CYCLE | AP_APP_CRACKED |
AP_APP_LIFE_CYCLE | AP_APP_OPEN |
AP_APP_LIFE_CYCLE | AP_APP_CLEAR_DATA |
AP_APP_LIFE_CYCLE | AP_APP_FOREGROUND |
AP_APP_LIFE_CYCLE | AP_APP_BACKGROUND |
AP_APP_LIFE_CYCLE | AP_APP_OUT_OF_MEMORY |
AP_APP_LIFE_CYCLE | AP_APP_FIRST_OPEN |
AP_APP_LIFE_CYCLE | AP_APP_LAUNCHING |
AP_APP_LIFE_CYCLE | AP_APP_RESIGN_ACTIVE |
AP_APP_LIFE_CYCLE | AP_APP_WILL_CONNECT |
AP_USER_LIFE_CYCLE | AP_USER_SIGNUP |
AP_USER_LIFE_CYCLE | AP_USER_LOGIN |
AP_USER_LIFE_CYCLE | AP_USER_LOGOUT |
AP_APPLICATION | AP_DEEP_LINK_OPEN |
AP_APPLICATION | AP_DEEP_LINK_UPDATE |
AP_APPLICATION | AP_DEEP_LINK_FIRST_OPEN |
AP_APPLICATION | AP_IN_APP_PURCHASE |
AP_APPLICATION | AP_NOTIFICATION_RECEIVE |
AP_APPLICATION | AP_NOTIFICATION_OPEN |
AP_APPLICATION | AP_NOTIFICATION_DISMISS |
AP_APPLICATION | AP_NOTIFICATION_FOREGROUND |
AP_APPLICATION | AP_SEARCH |
AP_APPLICATION | AP_BATTERY_LOW |
AP_APPLICATION | AP_BATTERY_FULL |
AP_APPLICATION | AP_LOW_POWER_MODE_ON |
AP_APPLICATION | AP_LOW_POWER_MODE_OFF |
AP_OTHERS | AP_NETWORK_REACHABILITY_CHANGE |
AP_OTHERS | AP_NETWORK_BANDWIDTH_CHANGE |
AP_OTHERS | AP_SWITCH_THEME_LIGHT |
AP_OTHERS | AP_SWITCH_THEME_DARK |
AP_OTHERS | AP_SWITCH_THEME_CUSTOM |
AP_OTHERS | AP_SWITCH_ORIENTATION_LANDSCAPE |
AP_OTHERS | AP_SWITCH_ORIENTATION_PORTRAIT |
AP_OS | AP_OS_UPDATE |
AP_OS | AP_OS_UNSUPPORTED |