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_CYCLEAP_APP_INSTALL
AP_APP_LIFE_CYCLEAP_APP_UNINSTALL
AP_APP_LIFE_CYCLEAP_APP_UPDATE
AP_APP_LIFE_CYCLEAP_APP_CRACKED
AP_APP_LIFE_CYCLEAP_APP_OPEN
AP_APP_LIFE_CYCLEAP_APP_CLEAR_DATA
AP_APP_LIFE_CYCLEAP_APP_FOREGROUND
AP_APP_LIFE_CYCLEAP_APP_BACKGROUND
AP_APP_LIFE_CYCLEAP_APP_OUT_OF_MEMORY
AP_APP_LIFE_CYCLEAP_APP_FIRST_OPEN
AP_APP_LIFE_CYCLEAP_APP_LAUNCHING
AP_APP_LIFE_CYCLEAP_APP_RESIGN_ACTIVE
AP_APP_LIFE_CYCLEAP_APP_WILL_CONNECT
AP_USER_LIFE_CYCLEAP_USER_SIGNUP
AP_USER_LIFE_CYCLEAP_USER_LOGIN
AP_USER_LIFE_CYCLEAP_USER_LOGOUT
AP_APPLICATIONAP_DEEP_LINK_OPEN
AP_APPLICATIONAP_DEEP_LINK_UPDATE
AP_APPLICATIONAP_DEEP_LINK_FIRST_OPEN
AP_APPLICATIONAP_IN_APP_PURCHASE
AP_APPLICATIONAP_NOTIFICATION_RECEIVE
AP_APPLICATIONAP_NOTIFICATION_OPEN
AP_APPLICATIONAP_NOTIFICATION_DISMISS
AP_APPLICATIONAP_NOTIFICATION_FOREGROUND
AP_APPLICATIONAP_SEARCH
AP_APPLICATIONAP_BATTERY_LOW
AP_APPLICATIONAP_BATTERY_FULL
AP_APPLICATIONAP_LOW_POWER_MODE_ON
AP_APPLICATIONAP_LOW_POWER_MODE_OFF
AP_OTHERSAP_NETWORK_REACHABILITY_CHANGE
AP_OTHERSAP_NETWORK_BANDWIDTH_CHANGE
AP_OTHERSAP_SWITCH_THEME_LIGHT
AP_OTHERSAP_SWITCH_THEME_DARK
AP_OTHERSAP_SWITCH_THEME_CUSTOM
AP_OTHERSAP_SWITCH_ORIENTATION_LANDSCAPE
AP_OTHERSAP_SWITCH_ORIENTATION_PORTRAIT
AP_OSAP_OS_UPDATE
AP_OSAP_OS_UNSUPPORTED