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.
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:
![mtiks1 mtiks1](http://blog.tomverhoeff.nl/wp-content/uploads/2012/03/mtiks1_thumb.png)
- Google Analytics (using MSAF)
- Flurry
- Preemptive Runtime Intelligence (less interesting since their deal with MS ended)
- mTiks
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:- Sign-up at the mTiks website
- Add your app to the list in you account. If you don’t have a marketplace url yet, just enter a – or anything
- Take note of the code for your app by selecting your new app from the list.
- 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:- In WMAppManifest.xaml make sure the following capabilities are set <Capability Name=”ID_CAP_IDENTITY_DEVICE”/> <Capability Name=”ID_CAP_IDENTITY_USER”/>
- Add a reference to mtiks.dll
- Open up your App.xaml.cs and add the following usings using com.mtiks.winmobile; using System.Reflection;
- 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(); }
![mtiks4 mtiks4](http://blog.tomverhoeff.nl/wp-content/uploads/2012/03/mtiks4_thumb.png)