Kevin McMahon

Chicago based mobile developer.

Monotouch: Flurry Analytics Bindings

The MonoTouch libraries can be found on my fork of monotuch-libs on GitHub

For an example of how to build and use the binding check out this example project on github.

For my latest app I wanted to collect some analytics to see which screens and content included in the app are the most useful to users. In evaluating my mobile analytics options, Flurry's free of charge service and easy to use API made the decision to go with them over Google Analytics and Mixpanel an easy one.Integrating Flurry analytics into your app is pretty easy but there is a small amount of setup to be done prior. You will need to grab the iPhone SDK from Flurry and also register your application with them to get an API key. The API key is unique to your application and provides Flurry a way to know who is sending events and notifications back to them to log. The SDK includes a couple header files and the Objective-C libraries you'll need to include and link against in your MonoTouch projects. Once the Flurry libraries and the MonoTouch bindings have been obtained and an API key has been generated, we can integrate them into MonoTouch application and start collecting data.Initiating data collection is as simple as calling the StartSession method with the application's API key. That is all it takes to start collecting basic information about your app like the amount of times it has been launched, the number of different users using it, and other bits of info like hardware version and service provider.Here is some code showing how to turn analytics on.

using System;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Flurry; // include the MonoTouch binding lib

namespace Foo
{
    [Register ("AppDelegate")]
    public class AppDelegate : UIApplicationDelegate
    {
        public const string FlurryApiKey ="...";

        public override bool FinishedLaunching (UIApplication app, NSDictionary options)
        {
            // 1 liner to kick the session off
            Flurry.FlurryAPI.StartSession(FlurryApiKey);

            // Do you app thing here...
        }
    }
}

If more detailed analytics are desired, there are additional methods available to help you glean whatever meaningful information you need from your application. The example below shows how you can automatically track the changes in navigation within a tab bar. When you pass a UINavigationController or a UITabBarController to the CurrentPageViews method, each navigation action as you move from one view or tab to another gets tracked. This is ideal for seeing which parts of your app users are interacting with the most.

using System;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Flurry; // include the MonoTouch binding lib

namespace Foo
{
    [Register ("AppDelegate")]
    public class AppDelegate : UIApplicationDelegate
    {
        public const string FlurryApiKey ="...";

        public override bool FinishedLaunching (UIApplication app, NSDictionary options)
        {
            // 1 liner to kick the session off
            FlurryAPI.StartSession(FlurryApiKey);

            // create a navigatable controller to watch...
            UITabBarController tabBarController = new UITabBarController();

            // ...and pass it to CurrentPageViews.
            FlurryAPI.CurrentPageViews(tabBarController);

            // Do you app thing here...
        }
    }
}

I am touching on just a few things that you can do with Flurry. The SDK docs describe a number of other things you can do like creating and logging custom events and tracking how much time is spent performing activities. I'd recommend checking them out after you download the libraries.I've just started collecting analytics during beta testing and things appear to working smoothly.

If you find any issues with the MonoTouch bindings please let me know. Enjoy!

Tagged: analytics / libs / sdk / iphone / google / objective-c / monotouch / binding / mobile

blog comments powered by Disqus