Android Integration Guide(inactive)

This page serves as a guide to integrate Android applications with Affle’s tracker SDK. This SDK helps in tracking downloads, installs, and in-application behavioral statistics. Application developers can choose to integrate components based on requirements.


Getting the SDK

The Affle tracker SDK can be downloaded from   here or from your account/business manager of the platform. The archive provided should contain the following files:

1. AffleTrackerSDK.jar  : SDK library for integration from the Google Playstore.

2. AffleTrackerSDK3rdParty.jar  : SDK library for integration from third party applications stores.

3. AffleInstallReceiver.java  : This file is provided to extended/implement the base class of the AffleTracker.

4. SDKProjectSettings.txt : :Download and in-app tracking URLs along with other app specific key settings.

*The developer responsible for integration must have sound knowledge of JAVA/ANDROID IDE.


Step one: Include the SDK in your project

1. Add AffleTrackerSDK.jar or AffleTrackerSDK3rdParty.jar to your project as a project library.

• If you’re using Eclipse, modify your Java Build Path, and choose Add External JAR.
• If you’re using the SDK tools directly, drop it into your libs folder and the ant task will pick it up.

2. Open AndroidManifest.xml in your project and add the following:

Permission to access Internet, Phone State and Network State.

< uses-permission android:name=”android.permission.INTERNET”/ >
< uses-permission android:name=”android.permission.READ_PHONE_STATE”/ >
< uses-permission android:name=”android.permission.ACCESS_NETWORK_STATE”/ >

 

 

Step two: Settings for download conversion tracking

If the requirement suggests, tracking the download conversion then use the following settings:

1. Add the AffleInstallReceiver.java file to your project files. Change the Package Name at the top of the file, to the package name of the main project.

2. Add the following RECEIVER
< receiver android:name=”.AffleInstallReceiver” android:exported=”true” >
  < intent-filter >
    < action android:name=”com.android.vending.INSTALL_REFERRER” / >
  < /intent-filter >
< /receiver >


Settings for Google Playstore hosted application

Under the Application section, add the following META-DATA // < application.... //... < meta-data android:name="affleDownloadPostBackURL" android:value="DOWNLOAD_TRACKER_URL" / > //... // < /application > The DOWNLOAD_TRACKER_URL value can be obtained from the SDKProjectSetting.txt file


Settings for app hosted on third party application stores or direct download


Under the Application section, add the following META-DATA // < application.... //... < meta-data android:name="affleDownloadPostBackURL" android:value="DOWNLOAD_TRACKER_URL" / > < meta-data android:name="appStoreName" android:value="STORE_NAME" / > //... // < /application >

Put this line of code in the first place your app run. Recommend onCreate() of Application.

AffleAppDownloadTracker ad2ctrackerObj = new AffleAppDownloadTracker(); ad2ctrackerObj.trackDownload(getApplicationContext(), null); The DOWNLOAD_TRACKER_URL&STORE_NAME values can be obtained from the SDKProjectSetting.txt file




Step three: Settings for in-app stats & purchase tracking

If the requirement suggests, tracking the in-app stats like page views, engagements, events, purchase Events & other analytics, then use the following settings:

1. Open the AndroidManifest.xml file in your project and add the following:
Under the Application section, add the following META-DATA

// < application….
//…
< meta-data android:name=”affleInAppPostBackURL” android:value=”INAPP_TRACKER_URL” / > //…
// < /application >

The INAPP_TRACKER_URL value can be obtained from the SDKProjectSetting.txt file

2. Call the following methods in your program to capture the Page Views, Engagements, Events, Purchase Events & other Analytics

Page view

To track your page or screen views in the app call, the method “inAppTrackerViewName” and pass the View Name that should be displayed on the analytics interface. Method public static void inAppTrackerViewName ( Context context, String viewName, String viewDetail, String eventName ) • Example for Home Screen: AffleInApptracker.inAppTrackerViewName (context, “home”,””,””);
• Example for category list screen:AffleInApptracker.inAppTrackerViewName (context, “Category1List”,””,””);
android page view

 


 


 


To track view or view detail. You can call the method in onResume method of the Activity.
onresume


Page view & details

To track your page or screen views & extra details in the app call, the method “inAppTrackerViewName” and pass the View Name & the Detail Description of the page that should be displayed on the analytics interface. Method public static void inAppTrackerViewName ( Context context, String viewName, String viewDetail, String eventName ) • Example for Category Detail Page with Title 1: AffleInApptracker.inAppTrackerViewName (context, “Category1Detail”,” Title1”,””); • Example for Category Detail Page with Title 2: AffleInApptracker.inAppTrackerViewName (context, “Category1Detail”, ”Title2”,””);


Engagement/Events

To track your Engagement/Events in the app, call the method “inAppTrackerViewName” and pass the View Name, the Detail Description of the page & Event/Engagement Name that should be displayed on the analytics interface.
Method public static void inAppTrackerViewName ( Context context, String viewName, String viewDetail, String eventName )

• Example for FB_LIKE on Home Screen: AffleInApptracker.inAppTrackerViewName (context, “home”, ””, ”fb_like”);
• Example for TW_SHARE on Category List Screen:
AffleInApptracker.inAppTrackerViewName (context, “Category1List”, ””, ”tw_share”);
• Example for RATING on Category Detail Page with Title 3: AffleInApptracker.inAppTrackerViewName (context, “Category2Detail”, ” Title3”, ”rating5”);
• Example for FB_SHARE on Category Detail Page with Title 4: AffleInApptracker.inAppTrackerViewName (context, “Category2Detail”, ” Title4”, ”fb_share”);

To track events, call the method on the place the event is triggered. For example, an event can be tracked though clicks using the code based method below.

 

android event track


Purchase

To track your Purchase Events in the app, call the method “inAppEventTrackerViewName” and pass the View Name, the Detail Description (if required), Purchase Event Name, Transaction Id, Purchase Amount of Transaction, and Purchase Quantity that should be displayed on the analytics interface. Method public static void inAppEventTrackerViewName ( Context context, String viewName, String viewDetail, String pevent, String ptid, String pamount, int pqty, ) • Example for Purchase on Movie Booking Detail Page:
AffleInApptracker.inAppEventTrackerViewName (context, “Movie1Title”, ””, “Movie1Name”, “12345”, 1000, 4); * Price of 1 Ticket = 250, 4 Tickets = 1000 • Example for Purchase on Taxi Booking Detail Page:
AffleInApptracker.inAppEventTrackerViewName (context, “TaxiCategory1”, ””, “YellowTaxi”, “abcd22344xxuz”, 1500, 1); *Price of 1 Ticket = 1500
• Example for Credit Purchase on Game Credit Purchase Page:
AffleInApptracker.inAppEventTrackerViewName (context, “Game1”, ””, “Credit”, “putc445ghfb”, 500, 1000)
credit purchase

 


 


 


 


 


 


This method is used to track purchase events. For example use this method to track in-app billing by calling it in place during purchase event success:
credit purchase result



SDK testing: Google Hosted

1. Ensure that the App does not pre-­exist on the Android device/emulator.
2. Open the tracking link provided in the SDKProjectSetting.txt file using a browser on the device/emulator.
3. Click the banner/tracking URL in SDKProjectSetting.txt
4. Load your App on the Android device/Emulator via the IDE & Open it.
5. Perform the following steps on the terminal:
Goto android-­sdk/platform-­tools
run ./adb shell
Execute the command:‐
am broadcast‐a com.android.vending.INSTALL_REFERRER‐n
com.affle.affletrackersdksample/.AffleInstallReceiver-­‐es “referrer”
“tid=8a6064bd1d9d7b60eba90c82e85b5640”
**

REPLACE com.affle.affletrackersdksample with Your Application’s Package Name

6. Validate from the logs printed in the DDMS of IDE.
7.You should be able to see the pings from either or both the configured URLs:
-­affleInAppPostBackURL
-­affleDownloadPostBackURL

8. Check to see if it was recorded in the Event Logs Report.
The event should be attributed to the same publisher as the inst all unless the event uses Re‐Engagement.



SDK testing: Third party Hosted

1. Ensure that the app does not pre‐exist on the Android device/emulator.
2. Open the tracking link provided in SDKProjectSetting.txt using the a browser on the device/emulator.
3. Click on the banner/tracking URL.
4. Load your app on the device/emulator via the IDE.
5. Validate from the logs printed in the DDMS of IDE.
6. You should be able to see the pings from either or both the configured URLs
-­affleInAppPostBackURL
-­affleDownloadPostBackURL

7. Check if activity was recorded in the Event Logs Report. The event should be attributed to the same publisher as the install unless the event uses Re‐Engagement.

*Note: The easiest way to test is to send an email with a tracking link, log file and the updated file for the Android app. From an Android device, conduct the test with the information from the email.



Integrating multiple download conversion tracking SDK through multiple receivers

1) If your Android app has multiple receivers for INSTALL_REFERRER, you will instead need to write a custom receiver that will call these receivers.

Create a new receiver class file AffleMultipleInstallReceivers.java (extending BroadcastReceiver) that looks something like this:
package com.affle.affletrackersdksample;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.affle.affledowloadtracker.AffleAppDownloadTracker;
public class AffleMultipleInstallReceivers extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
//call AffleAppDownloadTracker
AffleAppDownloadTracker ad2ctrackerObj = new AffleAppDownloadTracker();
ad2ctrackerObj.onReceive(context(),intent);

//Initialize and call onReceive for other receivers
}
}

2) Then place the receiver in your manifest file like shown below, but change the receiver name to
the one you created above.

<receiver android:name=”.AffleMultipleInstallReceivers” android: exported=”true”>
<intent‐filter>
<action android:name=”com.android.vending.INSTALL_REFERRER” />
</intent‐filter>
</receiver>