Note: This documentation is for Opentracker's events engine, please contact us if you think you need an upgrade.
Note: Before you can start using app analytics, you first need to register your app here

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.

7 easy steps to start tracking your app

Add iOS libraries 1 Signup or add your app to an existing account (receive signup email).
Add iOS libraries 2

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 3

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 4 Add the following import statement to your main Activity object:
Add Android methods 5 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 6 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.

Add Android manifest 7 Add the following to your application’s manifest AndroidManifest.xml (example)

Allows an application to open network sockets.
<uses-permission android:name="android.permission.INTERNET"></uses-permission>

Allows an application to access fine (e.g., GPS) location
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>

Allows an applications to access information about networks: needed for 
methods OTDataSockets.getNetworkType() and OTDataSockets.getNetwork();
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /></uses-permission>

Allows an applications to access information about Wi-Fi networks
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /></uses-permission>
8 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.

Power features

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]'

// Example of sending a multi-dimensional event
HashMap myEvent = new HashMap();
myEvent.put("title", "HP ad tapped");
myEvent.put("ad link", "");
myEvent.put("value", "$20");
myEvent.put("source", "Overview screen");



Opentracker's events engine includes counting functionality with segmentation within the API calls.

Info 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);


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 <manifest> element of the manifest file.


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

Visible in:

  • Apps & Browsers
  • All browser segments


We would love to hear your feedback. Please use the facebook comment box below