Screens in Android apps
Screens are the content that your users view in your app. Measuring screen views helps you to understand what is more engaging for your users.
Add the SDK
- Before your begin, make sure that Apptics is integrated into your project by following the Integration Guide.
- Declaring 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 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)
Automatic activity tracking
Activity traversals are tracked automatically on initializing the Apptics.
You can opt-out from automatically tracking the activity by setting the automaticActivityTrackingStatus to False.
Make sure to disable them before initializing Apptics.
CopiedAppticsAnalytics.automaticActivityTrackingStatus = false
Apptics.init(this)
Fragment tracking
Fragment traversals can be tracked automatically by enabling automaticFragmentTrackingStatus in AppticsAnalytics.
CopiedAppticsAnalytics.automaticFragmentTrackingStatus = true
Apptics.init(this)
If your app has R8 obfuscation enabled, keep the fragment class names from obfuscating to track proper class names.
Note: Fragment tracking is enabled by default in Apptics BOM versions between 0.2.6.0 to 0.2.12.0. Make sure to keep the fragment class names from obfuscating or disable fragment tracking manually using the above snippet.
Manual screen tracking
You can log screens manually using inScreen and outScreen method in AppticsScreenTracker end point.
Copiedval trackerId = AppticsScreenTracker.inScreen("ScreenName")
AppticsScreenTracker.outScreen(trackerid)
Call inScreen with screen name to mark that the screen is presented or visible to the user.
'inScreen' method returns a tracking id, which should be passed to 'outScreen' to mark that the screen is dismissed or not visible to the user anymore.