Would you like to contribute to the Titanium docs? To get started, sign up for an account on the Appcelerator Wiki and sign our CLA.

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Go to the Appcelerator Dashboard and create a new native Android application.
  2. Download the Services SDK and get your Analytics application key.
  3. Unpack the Services SDK ZIP file.
  4. Copy the the appcelerator-sdk-android-<VERSION>.jar  to the  lib  folder folder of your Android project.
  5. Modify the project's  AndroidManifest.xml  file to include the following permissions and to add the APSAnalytics package as a service: 

    Code Block
    titleAndroidManifest.xml
    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.appcelerator.sample"
        android:versionCode="1"
        android:versionName="1.0" >
    
        <!-- Add these permissions to enable Analytics -->
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
        <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
        <uses-permission android:name="android.permission.INTERNET"/>
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
                     android:maxSdkVersion="18" />
    
        <application>
            <activity>
                ...
            </activity>
     
            <!-- Add this service to enable Analytics -->
            <service android:name="com.appcelerator.aps.APSAnalyticsService"
                android:exported="false" />
    
    
        </application>
    </manifest>
  6. Add the following import statements to the main Activity of the project: 

    Code Block
    titleMainActivity.java
    import com.appcelerator.aps.APSServiceManager;
    import com.appcelerator.aps.APSAnalytics;
  7. In the main Activity's  onCreate()  method, enable the service by calling the APSServiceManager's enable  method.  Pass Pass the method the application context as the first argument and the APS application key as the second argument.  

    Code Block
    public void onCreate() {
        APSServiceManager.getInstance().enable(getApplicationContext(), "APP_KEY");
    } 
    Tip

    To get your APS App key:

    1. Go to the Appcelerator 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, Performance and Cloud section.

The Android application can now make additional method calls using the  APSAnalytics class.  Before making API calls to the APSAnalytics class, you need to retrieve a shared instance using the getInstance() method.  Make Make APSAnalytics API calls using the shared instance.

For the Android platform, you need to setup the application to send user session events

Advanced Initialization Options

...

You use the the A PSAnalytics API to log and report custom events. There are two main types of events you can capture: Feature Events and Navigation Events. Feature events are for capturing a user action, such as selecting a specific menu option, or launching a video. Navigation events track a user's movement through an application, such as going from the application's home screen, and then to a search screen.

...

Note

Currently, navigation events do not appear in Dashboard. As a workaround, consider using transition events.

In the following example, an event is generated when the user navigates from the application's home screen to an edit message screen:

...

Transition events

Currently, navigation events are not collected and presented in the Appcelerator Dashboard. As a workaround to this temporary issue, you can create "transition" events that serve the same purpose. A transition event is a feature event whose name uniquely identifies the user's navigation ("screen1-to-screen2", for example). You can create an event funnel in Dashboard from these events to analyze navigation within your application. 

...