Android App Tracking
For android apps
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
|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|
|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 the following import statement to your main Activity object:
| 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");
| 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 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 trackingAdd 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 eventsTo 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);
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 exampleThe 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 element of the manifest file.
myEvent.put("browser", "My cool app"); myEvent.put("browserVersion", "1.5.2");
- 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.