Skip to end of metadata
Go to start of metadata

Pro or Enterprise Subscription Required


This AMPLIFY Appcelerator Services feature requires a Pro or Enterprise Subscription. 

This page describes how to use the AMPLIFY Appcelerator Services Analytics for native Android applications, built with Java and the Android APIs.

Not developing a native Android application with Java?

See the following topics to use the Appcelerator Analytics Service on other platforms:

For native iOS applications built with Objective-C, see APS Analytics for iOS.


For Titanium Applications, see AMPLIFY Appcelerator Analytics.


AMPLIFY Appcelerator Analytics collects real-time data about your application's usage, which can then be viewed in the Analytics dashboard. By default, the Analytics dashboard provides information about app installs, the number of sessions, and average app session length (organized by app name, platform, and geography). Your app can also utilize custom analytic events and event funnels.

This document provides an overview of the features provided by Analytics and how to use them using the Titanium SDK. If you are developing an iOS application with Objective-C or Swift or an Android application with Java, see APS Analytics for iOS or APS Analytics for Android for details on using Analytics.

For platform-specific details about how analytics captured, see Analytics Architecture.

For information about viewing analytics data, see Managing Client Applications.


Analytics refers to data about how your application has been used, as well as information about how users interact with your application. Analytics data is transmitted in the form of events

Events are operational milestones in the application. Some events are generated automatically, such as those that mark an installation, or the beginning and end of a session. Others may be custom events, which have a meaning specific to an application, such as tapping a specific button or opening a certain window.

A feature event represents an action a user could take in an application, such as 'liking an item' or launching a video'. Applications use the Titanium or APSAnalytics API to create custom events.

Event funnels let you define custom, ordered event sequences that let you track a specific user process, such as finding a product and making a purchase.

The Analytics dashboard organizes, analyzes, and presents analytics data captured for your applications. You also use the Analytics dashboard to create and view event funnels.

Getting started

To integrate the Analytics service with a new or existing Android application:

  1. Go to the Dashboard and create a new native Android application.
  2. Download the APS (Appcelerator Platform Services) SDK and get your Services key.
  3. Unzip the APS SDK zip file.
  4. From the unzipped SDK's libs folder, copy the following files to your app project's libs folder:
    • aps-analytics.aar
    • aps-cloud.aar
    • aps-services.aar
  5. Open the build.gradle file under your Android app project folder and add the following dependencies block.

  6. Add the following import statements to the main Activity of the project: 

  7. In the main Activity's onCreate() method, enable the service by calling the APSServiceManager's enable()  method. Pass the method of the application context as the first argument and the APS application key as the second argument.


    To get your APS App key:

    1. Go to the Dashboard.
    2. Select your application from the Apps drop-down menu.
    3. Click the Overview tab.
    4. Click the Services button.
    5. Click Show Key under the Analytics and Cloud section.

Setup user session events

Unlike the iOS and Titanium platforms, user session events are not automatically sent on Android. You need to add 3 APSAnalyitcs method calls in the main Activity of your application to capture user session data.

  1. Call the sendAppInstallEvent() method in the activity's onCreate(), after enabling APSServiceManager. The enroll event indicates app installs or upgrades.
  2. Call the sendSessionStartEvent() method inside the main Activity's onResume() method. This event indicates when the app is being used.
  3. Call the sendSessionEndEvent() method inside the main Activity's onPause() method. This event indicates when the app has been backgrounded.

Custom events

You use the APSAnalytics' sendCustomEvent() method to generate a feature event that captures a specific application or user activity. A feature event should represent an action, such as launching a video, or 'new item', 'launch video', and so forth. The name you assign to a feature event should incorporate the application state into the event name, rather than long descriptive names. The following naming convention is suggested, where group.event refers to the parent event: group.event.sub-event

Feature event names should be as generic as possible. For instance, if you want to track when users select a certain menu option, use a name like "", not "". The first option is better because it groups all the same types of events into a single metric that's easy to view on Dashboard. The person analyzing the data only has to look at a single number to get an overview of how many users have selected that menu option. The second might be fine for very small user bases, but if you have more than 100 users, it means that the person analyzing the data would have to look through 100 different event names to be able to generate any useful data.

For example, to track a user's menu selection, you might use the following code, where the ten-digit number uniquely identifies the selection in your code: 

Good Practice: Track the State with the Naming Syntax

You should avoid using long, descriptive event names, as shown below:

Bad Practice: Avoid Long Descriptions