Use Usage Reporting in Your Android Application
- How the Usage Reporting feature works
- How to customize the consent screen
- How to further instrument the Wizard app
- How to add code to enable auto-upload of usage data based on the client policy
Prerequisites
- You completed Try Out the SAP BTP SDK Wizard for Android.
- Step 1
As shown in the tutorial, Try Out the SAP BTP SDK Wizard for Android, ensure that Enable Usage Reporting is checked when creating the app.
When the app is first installed, a consent screen will automatically be shown to users.
The app must first receive permission to collect usage information from the user.
-
Tap ALLOW to allow the app to record how the app is being used.
If DENY was selected, the user’s choice can later be changed in the app’s Settings screen.
Once you try to enable Consent to Usage Collection, the consent screen will be displayed again to confirm your choice.
-
From the Settings screen, tap Upload Usage Data.
The Consent to Usage Collection will be disabled and cannot be enabled if usage was not enabled in the Mobile Services cockpit.
-
To review this policy setting, in the Mobile Services cockpit, access Mobile Client Usage and User Feedback by navigating to Mobile Applications > Native/MDK > com.sap.wizapp > Mobile Client Usage and User Feedback.
The Client Usage Configuration specifies whether uploads of usage data are allowed and the time interval between automatic usage report uploads.
The preset value for Upload Report After is 0 (usage reports will not be uploaded automatically), which we will use in the implementation of automatically uploading usage reports to the server. Finally, click Save to save any changes.
-
If an empty usage report notification is shown when Upload Usage Data is selected, navigate away from the app by going to your phone’s Home screen and re-entering the app. Then try uploading the usage report again. Placing the app in the background will complete or end the current usage session. Partial sessions can not be uploaded.
If Upload Usage Data was successful, then a Toast message should pop up informing you that the usage information has been uploaded to the server.
Which of the following actions must be taken to enable usage in an app?
-
- Step 2
-
To view the application usage report, go to your management cockpit under Analytics > User Data.
Different charts become available when you select between Sessions, Demographics, and Behavior in the drop-down (green) box. The mark in the yellow box controls whether to display filters that are in the red box right below.
-
To download the usage report, go to Mobile Applications > Native/MDK > com.sap.wizapp > Mobile Client Usage and User Feedback. You can filter the data by changing the value of the Last 7 Days dropdown. Click the Download icon to export the filtered data to a
.csv
file. -
Open the downloaded
clientUsage_uploads.csv
. The file contains usage entries from the app that record different actions, such as button taps and timers.Column Description APPLICATIONID
Identifies the app the usage report events were generated from DEVICEMODEL
Device type (Samsung, Android Emulator, etc.) DEVICEPLATFORM
Android or iOS DEVICEVERSION
Device software version REGISTRATIONID
A unique ID generated when you first register your device USERSESSIONID
A unique ID generated every time the application is re-opened RECORDKEY
What kind of information is being described (information about the device ( DeviceInfo
), an event within the application (BehaviorEvent
), etc.)RECORDTYPE
BehaviorEvent
type (e.g.viewDisplayed
,userInteraction
)TIMERSTART
Time the event began TIMERDURATION
How long an event ran for, in seconds I_SCREEN
Screen resolution of the device using the current OSLifecycle
state as the keyI_VIEW
The name of the Screen/View where BehaviourEvents
are generatedI_ELEMENT
UI element or screen control that was interacted with I_ACTION
Action that the user performed I_VALUE
Value related to the interaction, if applicable In the following example, there are three different Android devices with varying software versions.
In the next example, the timer recorded how long the user kept the application active on their device before exiting for five different sessions. Recording how long users spend in the application is a typical measurement. You can also specify other processes to time, such as application startup, data requests, or the time taken to open an offline store.
A session is typically defined as how long the app has been open for in the foreground, but different records within the application can also be modified to act as sessions.
-
There can be multiple
USERSESSIONIDs
associated with a singleREGISTRATIONID
.REGISTRATIONID
is independent of your username and you can see a complete list of all user registrations for the app in the Mobile Services cockpit by navigating to Mobile Applications > Native/MDK > com.sap.wizapp > Mobile Settings Exchange > User Registrations.In the following example the same user registered on two different devices and ran three user sessions.
When the application is initially launched, the report will contain entries that describe the device screen, memory and networking capabilities in a condensed form in four columns, marking the end of a session.
I_VALUE
Description EnterApplication
Screen resolution of the device ( I_SCREEN
)location
Location permission for the application (denied or authorized); if authorized then it will list the latitude ( I_VIEW
), longitude (I_ELEMENT
), and city (I_ACTION
)device
Reiterates the screen resolution ( I_SCREEN
andI_VIEW
), device platform (I_ELEMENT
), and specifies the device language (I_ACTION
)memory
Device RAM ( I_SCREEN
), internal storage (I_VIEW
), and available space on the SD card (I_ELEMENT
)The app also records a few of the screens that user opens, and more usage reporting statements can be added in the code to track other specific screens.
In the example below, the user navigated to the Entity List screen, accessed the categories at positions 6 and 1, then entered the Settings screen.
What does the Usage Reporting feature do?
-
- Step 3
The Usage feature can be used to instrument an app to track things that might provide insight into a user’s behaviors.
The following steps record how often users start adding or updating products but cancel their changes. This is somewhat similar to a metric in a shopping cart type app, where it might be interesting to know how often items are added to a shopping cart, but the sale is not completed.
- Step 4
Mobile Services provides a Client Usage Configuration under Mobile Client Usage and User Feedback specifying whether uploads to Mobile Services are allowed and how often they should occur. The following instructions demonstrate how to modify the app to read and store the configuration (same as the concept of the following
policy
) and upload the usage data to Mobile Services using the specified interval.See Client Usage and Step by Step with the SAP BTP SDK for Android — Part 8 — Client Usage for further information on usage.
Congratulations! You have learned how the usage feature can provide insights into how a deployed application is being used!