Adding Analytics to your Windows Phone 7 App with Preemptive Solutions

I have always been interested in learning which features of my application users are using as well as if they are using it.  I have done this with other applications by using my own “home-grown” version of web services, etc. Since I have been working a lot with Windows Phone 7 lately, I decided to learn how to do this and share with the community. Before you get started you will be pleased to know that you won’t have to spend any money *at least until 2012* to do this with your existing phone apps.

To get started: 

Download Dotfuscator at http://www.preemptive.com/windowsphone7.html. After it is downloaded you will want to add your WP7 .XAP file to Dotfuscator. This will allow you to setup analytics and obfuscation of your application.

image

After it is loaded then you will want to click on the Input tab and take a look at the .DLL’s referenced in your project.  You will want to exclude any third party dll’s from the package. Don’t worry as they are not excluded entirely. The only thing you want left in here is your main application .dll and the Package Artifacts. So in the example below, I removed the Telerik 3rd party controls and only left my michaelcrump.net.dll and Package Artifacts.

image

You will now want to click on Settings and look for Instrumentation. Make sure that the first three are set to Yes. 

SNAGHTML11e103b

Now we are going to click on the Instrumentation Tab and right click our main application .dll and add an attribute.

SNAGHTML11f99b5

Select “PreEmptive.Attributes.Application.Attribute”.

SNAGHTMLeb5f820

You should have this screen now. This allows you to setup the Application Type and give it a name that you can see in your Preemptive Solution Dashboard. Go ahead and fill in your applications info. You can uniquely generate a GUID by clicking on the ellipse button in the right hand corner box.

SNAGHTML1215fc1

Once that is complete you are going to want to add a BusinessAttribute. So right click again and select BusinessAttribute.

SNAGHTMLeb5f820

At this point, you will want to fill in your company name as well as the CompanyKey that was provided in an email from Preemptive Solutions.

SNAGHTML1226231

Now that we have included our Application and Business information to our project. We will need to setup our SetupAttribute and TearDown Attribute.

Starting with the SetupAttribute:

Navigate inside your Application until you get to App –> Then InitializeComponent: void(). Right click on this field and add a SetupAttribute. You will want to make sure the Custom EndPoint is set to wp7data.runtimeintelligence.com/PreEmptive.Web.Services.Messaging/MessagingServiceV2.asmx. This is a selectable option, so you will not have to type it. This is basically a web service that will collect data as your users click on different items in your application.

SNAGHTML12370e1

Now the TeardownAttribute:

Navigate inside your Application until you get to App –> Then Application_Closing event. Right click on this field and add a TearDownAttribute. You can leave all the options on this page as the default.

SNAGHTML1245f64

Now comes the fun part, adding Attributes to the features you want to track. 

So for example: In my application I have four buttons on the main page. I have added the following attributes to track when a user clicks on each of them.

So right click on your click event and add a FeatureAttribute. In the example below you will see that I added 4 FeatureAttributes to my project.

SNAGHTML12533e1

You should name them where you can easily find them in the Preemptive Dashboard (screenshots coming up). For example on my AboutButton, I named it AboutButtonClicked.

image

Now all you will need to do is hit the Run Button and your application will recompile with the necessary files/references needed to communicate with Preemptive’s webservice.

 

After you run your application a few times you can go and check your results by going to the portal site at: http://wp7.runtimeintelligence.com/portal/Security/Logon

This will give you a snapshot of your application and queued data. You can drill in to see more info.

image

I drilled into michaelcrump.net and found exactly how many times users were clicking on my button. This new version of my app had only been out a few days and I quickly realized that most people use my RssFeed button than any other feature of my app. This is valuable information as it could tell you what features to drop or which ones you should improve on.

image

You also get a nice little graph at the bottom of the dashboard that tells what locations your users are in. You can hover over each one more more stats. 

image

What was very interesting to me was during application certification, I could see the location of the testers. This was very cool to see.

Overall I’m very impressed with the services that Preemptive Solution provided. From everything that I gathered this service was going to be free until January 2012. If you decide not to pay then you won’t have to resubmit your application. It will still work, you just won’t have any access to the data it provides.

 

Thanks for reading and please subscribe to my blog or follow me on twitter.

alt Subscribe to my feed



windows-phone7 wp7
Posted by: Michael Crump
Last revised: 06 Mar, 2012 12:56 AM

Comments

No comments yet. Be the first!

No new comments are allowed on this post.

Hosting provided by http://www.DiscountASP.NET