WP7 app analytics using mTiks in just 5 minutes

Written by Tom Verhoeff on. Posted in MSP, WP7

This post is part of a follow up series on my TechDays session on “Making Money with Windows Phone applications”. See this post for more info and an index. mtiks1 Why build in analytics into your mobile application? This subject has been covered in many blog posts an their conclusion is usually the same. First of all you just want to know how many people use your app and how often they do it. But knowing (at least to some extent) what part of your app is used the most and what epic feature is never found by users is also valuable. As a developer there’s plenty of frameworks to choose from:
In this post I will cover mTiks, since it’s just too easy to get started. You’ll be able to instrument your app in literally just a few minutes.

Preparation

Let’s take a look at the easy steps to get started:
  1. Sign-up at the mTiks website mtiks3
  2. Add your app to the list in you account. If you don’t have a marketplace url yet, just enter a – or anything
  3. Take note of the code for your app by selecting your new app from the list.
  4. Download the WP7 binary

Setup

Now you’re all set to integrate mTiks into your application, start by opening up your project in Visual Studio. Now follow these steps:
  1. In WMAppManifest.xaml make sure the following capabilities are set <Capability Name=”ID_CAP_IDENTITY_DEVICE”/> <Capability Name=”ID_CAP_IDENTITY_USER”/>
  2. Add a reference to mtiks.dll
  3. Open up your App.xaml.cs and add the following usings using com.mtiks.winmobile; using System.Reflection;
  4. Now all you need to do to start measuring is add the following code to the app’s lifecycle events
    // Code to execute when the application is launching (eg, from Start) 
            // This code will not execute when the application is reactivated 
            private void Application_Launching(object sender, LaunchingEventArgs e) 
            { 
                mtiks.Instance.Start("<code>", Assembly.GetExecutingAssembly()); 
            }
    
            // Code to execute when the application is activated (brought to foreground) 
            // This code will not execute when the application is first launched 
            private void Application_Activated(object sender, ActivatedEventArgs e) 
            { 
                mtiks.Instance.Start("<code>", Assembly.GetExecutingAssembly()); 
            }
    
            // Code to execute when the application is deactivated (sent to background) 
            // This code will not execute when the application is closing 
            private void Application_Deactivated(object sender, DeactivatedEventArgs e) 
            { 
                mtiks.Instance.Stop(); 
            }
    
            // Code to execute when the application is closing (eg, user hit Back) 
            // This code will not execute when the application is deactivated 
            private void Application_Closing(object sender, ClosingEventArgs e) 
            { 
                mtiks.Instance.Stop(); 
            }
Now fire up your app and close it down again. This should be enough for your first results (but you can always repeat running your app a few times). If you open up the mTiks Dashboard (make sure you select the right app in the upper right corner) you should see the first results coming in. This is one of the advantages of mTiks over for example Google Analytics, results get counted instantly. Also notice in the Usage Reports of the dashboard that mTiks already tracks things like App Version, Device and OS version without requiring any extra line of code. mtiks4

Event tracking

To collect a little more information on how your app is used there’s the option to track events. Just like the above steps it’s just ridiculously easy. There’s only two calls you need to know. Use mtiks.Instance.postEventAttributes(“<name>”); to simply count an event. It will give you a counter in the mTks dashboard. Use mtiks.Instance.postEventAttributes(“<name>”,Dictionary<string,string>) to collect a dictionary of attributes which can also be viewed through the dashboard. For example: mtiks.Instance.postEventAttributes(“<name>”,new Dictionary<string,string>{{“attribute1″,”value1”},{“attribute2″,”value2”}});

It’s free!

Now that you got everything up and running there’s one thing that really needs to be emphasized. mTiks offers all of this totally free. So there’s basically no reason to not implement this. It will give you valuable data that will come in handy some day. Just remember to respect your user’s privacy, so don’t collect any personal information (if applicable) through mTiks. If you have any questions or comments regarding this article feel free to contact me through the comments, contact form or Twitter.

Tags: , , , , , , ,

Trackback from your site.