Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Replaced /titanium/ links with /platform links

...

  1. Go to the 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 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
    linenumberstrue
    languagexml
    <?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
    languagejava
    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  method. Pass the method the application context as the first argument and the APS application key as the second argument.

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

    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, Performance and Cloud section.

...

For the Android platform, you need to set up the application to send user session events.

Advanced initialization options

...

Creating custom events

You use the A PSAnalytics API to log and report custom events. Feature Events  are for capturing a user action, such as selecting a specific menu option or launching a video.

...

You use the APSAnalytics' sendAppFeatureEvent()  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 "user.menu.selection", not "joeuser.menu.selection". 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 10 digit number uniquely identifies the selection in your code: 

...