Request a Demo Start Trial
Android Analytics
Download Android Analytics SDK
version 1.1.2

Android Application

Introduction

This document will take you through the first steps of integrating the Deskmetrics SDK with your own Android Java app.

We will make use of Deskmetrics-release.aar from the SDK zip

First steps:

The integration:

In the onCreate handler of your MainActivity class you should initialize the Analytics instance, set some properties, and start the SDK:

// ... android related initialization ...
// Initialize the SDK using the app key you can obtain from your dashboard
Analytics analytics = Analytics.initialize(this, "<MY APP KEY HERE>");
// Set some properties that are good to include with your events:
// This field is also referred to as the build id, the dashboard may automatically filter on it
analytics.setProp("tracking_id", "<MY TRACKING ID>");
analytics.setProp("sub_id", "<MY SUB ID>");
analytics.setProp("channel", "<MY CHANNEL>");
// A custom property:
analytics.setProp("custom_greeting", "hello friends");
// Now to start the SDK
analytics.start();
// We can now send events
analytics.send("greeting");
// We can also send events with custom data:
JSONObject bookData = new JSONObject();
try {
    bookData.put("author", "Raymond Chen");
    bookData.put("title", "The Old New Thing");
}
catch(JSONException e) {
    // ...
}
analytics.send("book", bookData);
// ... perhaps more android related initialization ...

Last words