Over a million developers have joined DZone.

Advanced App Analytics with Kii

· Mobile Zone

Visually compose APIs with easy-to-use tooling. Learn how IBM API Connect provides near-universal access to data and services both on-premises and in the cloud, brought to you in partnership with IBM.

There's more to mobile app success than having a reasonable strategy, an attractive UI design and solid development. Analytics is key to measuring the execution and value of all the important things that happen within your app. Developers usually have access to generic numbers such as installs and activations, but those fall short of the insight needed to steer the application in the right direction and adapt the app to your users’ needs.

There are many aspects to take into consideration when defining your app analytics strategy but one of the top ones is to make sure you pick a provider you can grow with. If you have an iOS app and are looking to create an Android version for example make sure you pick an analytics provider that supports your app across multiple platforms. If you’re considering monetizing your application through in-app advertising, you might want to use an analytics provider that also has partnerships with ad networks and offers app distribution opportunities. Choose a vendor that can handle your needs as your product scales, whether that means covering different platforms, devices or geographies or providing you with custom ad-hoc intelligence about your app.

Kii Analytics is particularly interesting in this area because it goes beyond basic analytics (eg. number of users in your app, ad impressions and clicks, files downloaded, object stored, etc) by allowing you to get analytics in terms of your application data and event data. You can define custom metrics and create multiple dimensions per metric - Kii will automatically take care of the aggregation and visualization. A very simple example of this within a game might be taking the Average Score sliced by Player Type.

So let's take a look at how to set up advanced analytics with Kii in an Android application:

1. If you haven't done this already please go ahead and register an application in our developer portal (a step by step guide on how to do that is available here). Write down the APP_ID and APP_KEY (you'll need them for the next step).

2. Now we need to add the Kii Analytics SDK to our Android project. It involves editing AndroidManifest.xml, adding a jar file to the project, adding a Proguard element in the config and adding one line of code for initialization. It's quite straightforward and explained here but the one line of code added to the method onCreate() in the main activity looks like this:

       Constants.APP_ID,   // App ID
       Constants.APP_KEY,   // App Key
       KiiAnalytics.Site.US);   // Backend region

3. You're all set. You can choose to do analytics based on application data or event data. If you decide to use only application data there's no need to keep modifying your app. It's enough with the single line of code of the step above (the rest is configured and visualized via the developer console). Alternatively, you can access analytics data from within the app itself using the SDK or via REST APIs for custom analysis (for an example take a look at section 3 in this page).

4. So let's assume that you decided to use application data for your analytics and you wish to see the information in the console. It's then time to define your metrics via the console. Simply make a note of the bucket name that you're using to store the data to be analyzed and the names of the fields that you use. For example if you're storing objects like this:

KiiUser user = KiiUser.getCurrentUser();
KiiBucket bucket = user.bucket(Constants.BUCKET_NAME);
KiiObject object = bucket.object();
object.set(Field.NAME, name);
object.set(Field.TYPE, type);
object.set(Field.SCORE, score);

write down the real values of BUCKET_NAME, Field.NAME, Field.TYPE and Field.AMOUNT.

With that information you can define and aggregate metrics on demand for those objects via the console as defined here.

Usually, it’s best to allow up to 24 hours so the data can be tracked and the end result will look like this in the console (for a single metric, you can define as many as you want):

As you can see, having your data on the cloud gives you great power over the kind of analytics that you can get from your app. Kii Analytics is so versatile that you can:

  • Define your metrics for data that is already on the Kii Cloud or that you send explicitly

  • Visualize aggregated metrics in the Developer Portal

  • Retrieve aggregated metrics via APIs

  • Define metrics in the Developer Portal

In my next entry I will show you how to work with Event Data explicitly pushing data to Kii for analysis. For a full guide on how to use our analytics feature on Android please see this page.

Stay tuned by following our developer blog  and Twitter!

The Mobile Zone is brought to you in partnership with Strongloop and IBM.  Visually compose APIs with easy-to-use tooling. Learn how IBM API Connect provides near-universal access to data and services both on-premises and in the cloud.


The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}