Click here to Skip to main content
13,351,243 members (49,902 online)
Click here to Skip to main content
Add your own
alternative version


11 bookmarked
Posted 22 Mar 2011

Adding Analytics to your Windows Phone 7 App with Preemptive Solutions

, 22 Mar 2011
Rate this:
Please Sign up or sign in to vote.
Easy way to add Analytics to your Windows Phone 7 App with Preemptive Solutions

Editorial Note

This article appears in the Third Party Products and Tools section. Articles in this section are for the members only and must not be used to promote or advertise products in any way, shape or form. Please report any spam or advertising.


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 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.


After it is loaded, you will want to click on the Input tab and take a look at the .DLLs referenced in your project.  You will want to exclude any third party DLLs 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 and Package Artifacts. 


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


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


Select “PreEmptive.Attributes.Application.Attribute”. 


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. 


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


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. 


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 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.


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. 


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. 


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


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

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


I drilled into 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. 


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 for more stats.  


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


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior) Telerik
United States United States
Michael Crump is a Silverlight MVP and MCPD that has been involved with computers in one way or another for as long as he can remember, but started professionally in 2002. After spending years working as a systems administrator/tech support analyst, Michael branched out and started developing internal utilities that automated repetitive tasks and freed up full-time employees. From there, he was offered a job working at McKesson corporation and has been working with some form of .NET and VB/C# since 2003.

He has worked at Fortune 500 companies where he gained experience in embedded systems design and software development to systems administration and database programming, and everything in between.

His primary focus right now is developing healthcare software solutions using Microsoft .NET technologies. He prefers building infrastructure components, reusable shared libraries and helping companies define, develop and automate process standards and guidelines.

You can read his blog at: or follow him on Twitter at @mbcrump.

You may also be interested in...


Comments and Discussions

GeneralMy vote of 5 Pin
Andy Pierrepoint25-Oct-11 4:03
memberAndy Pierrepoint25-Oct-11 4:03 
Many Thanks, saved me some time, much appreciated.
GeneralMy vote of 5 Pin
Kunal_Chowdhury22-Mar-11 9:33
mvpKunal_Chowdhury22-Mar-11 9:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.180111.1 | Last Updated 22 Mar 2011
Article Copyright 2011 by mbcrump
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid