Mobile App Analytics Made Easy

I’m a new Android mobile application(app) developer and have been working on my first app for a couple of weeks.

Before I started coding, I knew I needed to know how my users would interact with the app.

To sum up my philosophy: “If you can’t measure it, you can’t manage it” — Peter Drucker. It applies to everything you do. Especially mobile apps.

I figured as a newbie developer, it would be a good idea to collect as much data as possible from the very beginning. By collecting actionable data upfront, I can test, learn and iterate much faster. This also results in a better experience for my users, as I can be more proactive in dealing with app issues and roll out relevant features faster.

I am going to show you one way of collecting mobile app usage data, with a minimum amount of work.

Before we jump into the tutorial, let me cover the analytics backend requirements first.

Analytics Requirements

  1. Light weight and easy to get data in
  2. Horizontally scalable
  3. Support SSL/TLS
  4. Extensible schema
  5. Extensible plugins
  6. Near real time analysis of incoming data
  7. Easy to use, query and reason about ingested data
  8. Alerting and threshold support
  9. Easy to get data out
  10. Low cost/free

So I settled on using Graylog, since it met the above requirements perfectly.


Software/hardware ingredients you will need for this tutorial:

  1. Graylog OVA (you can roll your own if you choose)
  2. Android Studio
  3. Android smartphone or you can use the Android Studio emulator
  4. GELF Client (sends messages to the Graylog server(s))
  5. Netty Library (network transport)
  6. Jackson Library (JSON encoding)
  7. Slf4j Android (logging facade used by GELF client)

I am going to assume that you are a developer/have basic development skills. Thus I won’t go into detail about how to include or build the various libraries into your Android app.

Here are the steps:

  1. Setup your Graylog server
  2. Configure a GELF TCP input
  3. Add/build the libraries listed above to into your Android application
  4. Add GELF logger method:

Sample Method

public void gelfLogger(String appMessage) throws Exception {
final GelfConfiguration config = new GelfConfiguration(new InetSocketAddress(ipAddress, port))
final GelfTransport transport = GelfTransports.create(config);
final GelfMessageBuilder builder = new GelfMessageBuilder("", ipAddress)
.additionalField("_version", "1");

final GelfMessage message = builder.message(appMessage)

5. Set correct DNS/IP address and port, by passing it as a method input or as a global variable.

6. Test method — make sure you use try/catch exception handling

7. Check Graylog UI

Time Series Analysis — My Application
Geo Location — My Application

Now, if you want to turn this into a proper analytics web service, you will need to enable SSL (which is supported in GELF) and run your Graylog server in the cloud.

I am using Carina @ Rackspace and I have my own public domain name. I can send data from any app anywhere to the Graylog analytics service.

So there you go! It’s really very simple to send application data into Graylog.

If you have any questions, please feel free to post them here.