Android App Tracking

For android apps

Add iOS libraries Dont have an account?  Signup or add your app to an existing account. Opentracker's events engine supports tracking of Android users. This is done by including the Opentracker java library in your app and following the instructions below. The Opentracker library includes functions and listeners so you can easily insert your custom events into Opentracker.net's events engine.

6 easy steps to start tracking your app

Add iOS libraries

1

Download the android client zip file and unzip. You should now have a folder called Opentracker-android-xxx Or browse the code On Github and see if you like it
Add Opentracker analytics native app tracking Android libraries

2

Open your project in Eclipse, and add the the 'net' folder (located in the 'src' directory) into your project's source in order to include the tracking library. This will add 3 folders (android, android test, android example)to your project, you can take a look at the example files and safely delete once you are familiar with implementing. A pretty good article on how to use Eclipse with Android can be found here
Add Android import

3

Add the following import statement to your main Activity object:
import net.opentracker.android.*;
		
Add Android methods

4

In your onCreate method add the following code (example)
// Return the Context of the Activity to access its resources
appContext = this.getApplicationContext();
      
// Initiate opentracker's logging service, with the Context and your registered app name
OTLogService.onCreate(appContext, "your-registered-app-name");
      
// Record an event with the title "Activity started", but you can call it anything you want
OTLogService.sendEvent("Activity started");
		

More information on Context can be found here More information on Activity can be found here

Add Android methods

5

In your onPause method add the following code (example)
// Close the session and upload the events..
// The onPause method is guaranteed to be called in the life cycle of an Android App.
OTLogService.onPause();

// Record an event when the activity is paused, you can call it anything you want
OTLogService.sendEvent("Activity paused");
		
Add Android manifest

6

Add the following to your application's manifest AndroidManifest.xml (example)
     <!-- http://developer.android.com/reference/android/Manifest.permission.html -->


     <!-- Allows an application to open network sockets. -->



     <!-- Allows an application to access fine (e.g., GPS) location -->



     <!-- Allows an applications to access information about networks: needed for methods OTDataSockets.getNetworkType() and OTDataSockets.getNetwork(); -->



     <!-- Allows an applications to access information about Wi-Fi networks -->
		

Basic event tracking

Add your events (as many as you like, anywhere you see fit, just like logging).
// Record an event with the title "My event", but you can call it anything you want.
OTLogService.sendEvent("My event");

In order to avoid collecting too much data, do not call this function in a loop.

Multi-dimensional events

To use OTLogService to its full potential, you can add key/ value pairs to mark an event. For example if you have an event going to an advertisement use the following We recommend adding a title key/ value pair. If there is no title defined, the title will default to '[no title]' Keys are case sensitive, hence title value can only be defined for the key 'title' or 'ti'.
// Example of sending a multi-dimensional event
HashMap myEvent = new HashMap();
myEvent.put("title", "HP ad tapped"); 
myEvent.put("ad link", "http://www.hp.com/external/link.html");
myEvent.put("value", "$20");
myEvent.put("source", "Overview screen");

OTLogService.sendEvent(myEvent);

Counting

Opentracker's events engine includes counting functionality with segmentation within the API calls. Please see inserting events with a url for more details on the mechanics.

An example

The following example will add a shopping cart event:
// Example of sending a custom event
HashMap map = new HashMap();
map.put("item", "Panasonic Lumix DMC-TZ30");
map.put("brand!", "Panasonic");
map.put("price", "257");
map.put("item-type", "camera[+257]");
OTLogService.sendEvent("Checkout complete", map);

Click here to see a fully working javascript example

Example

A full example of an android eclipse project can be checked out at Github

Overriding default properties

In certain cases you might want to override some values for certain properties. See below for instructions on how to do so.

App & Browsers

This property can only be overridden in Android and iOS. You can override the default browser or App name by submitting the 'browser' variable. You can also specify a version. For Apps, not providing a browser variable will default to "unknown" and "version" will be specified as per version attributes in the element of the manifest file.

Example

myEvent.put("browser", "My cool app");
myEvent.put("browserVersion", "1.5.2");

Visible in:

  • Apps & Browsers
  • All browser segments

Opentracker's events engine supports tracking of Android native app events. This is done by including the Opentracker Android net folder in your app and following the instructions below. Opentracker's events engine includes functions and listeners so you can easily insert your custom events into our tracking/ logging engine.