In-app Events
- Configure the Events in the Apptics web console, refer to the User Guide.
- Add the AppticsAnalytics dependency in your project's module level build.gradle file.
Copieddependencies {
implementation "com.zoho:apptics-analytics:0.1"
}- While syncing the project with gradle files of the app, Kotlin enum class is generated automatically for the events configured in the Apptics console. Initialize the AppticsAnalytics class in your app's Application class's onCreate() method as given below.
CopiedAppticsAnalytics.init(applicationInstance)Use Events as Kotlin enums
- Call AppticsAnalytics.addEvent(AppticsEvents.groupname.eventname) to add events.
- Groupname is the event group name configured in the web console.
- Eventname is the event name configured in the web console.
CopiedAppticsAnalytics.addEvent(AppticsEvents.eventName);Use Events as Strings
- You can use Events as Strings in Apptics by adding the following in your project's module-level build.gradle file.
Copiedapptics {
// other apptics configs
supportEventAsString = ["default": true]
}- To add Events as Strings, you can use string literals in AppticsAnalytics.addEvent() method.
CopiedAppticsAnalytics.addEvent(eventName : String);Note: Strings should be the same as configured in the Apptics web console. AppticsEvents class is also generated for the strings configured in the Apptics web console.
Add custom properties to events
- Add custom properties to events, by calling any of the below method.
CopiedAppticsAnalytics.addEvent(String, JSONObject)
AppticsAnalytics.addEvent(AppticsEvents.eventName, JSONObject)