Click here to Skip to main content
12,693,601 members (28,918 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as



Using Application Insights with a new Windows Store App

, 15 Apr 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
If you haven't heard or read about Application Insights you should go to MSDN and read up on all the awesomeness that you can get by using this new feature of VSO. You can also take a look at the Channel 9 series on Application Insights for Visual Studio Online by Charles Sterling.

If you haven't heard or read about Application Insights you should go to MSDN and read up on all the awesomeness that you can get by using this new feature of VSO. You can also take a look at the Channel 9 series on Application Insights for Visual Studio Online by Charles Sterling.

Also see Using Application Insights with an existing Windows Store App for an example of adding Application Insights to an existing application that could already be in the store.

Create a new Application

If you you have the Application Insights Tools for Visual Studio installed that Brian Harry mention in one of his latest blog posts and you are creating a new application, this is much similar for you. Click the Add Application Insights to Project drop down, that will make sure you are authenticated to VSO.


Once done you will be able to choose which VSO account you want to connect to and then you can click Configure to choose the application name (if you haven't created an application in Application Insights yet just type the name and one will be created for you automatically).


At this point the application is opened in your default browser


and a solution is created like


Changing App Configuration

All applications (at the moment) new or current will get the error below if you haven't already changed the Platform of your store application


To get rid of this message and put Application Insights in a state where you can start logging application usage you will need to change the configuration of your app to not be Any CPU.

Open Configuration Manager


Set the platform to x86, x64, or ARM


Initializing Application Insights

Open the App.xaml.cs file and at the end of the App() method add the following code

Microsoft.ApplicationInsights.Telemetry.WindowsStore.ClientAnalyticsSession.Default.Start(<span style="color: #006080">"license key from ApplicationInsights.config"</span>

As the snippet mentions you need to grab the license key (aka: instrumentation key) from the ApplicationInsights.config


At this point you can run your application and you will get some basic information like the Operating System, Screen Resolution and a view metrics like session time. You'll need to wait about 15 minutes for the information to display on your dashboard but will look something like below.


To see the data head over to the Usage Tab on VSO Application Insights


Logging app feature usage

Because I am using a new application I will just log which of the groups the user clicks into. To do this (if you are using the Split Page Application) navigate to ItemsPage.xaml.cs file and change the ItemView_ItemClick method to be like below

<span style="color: #008000">/// <summary></span><br><span style="color: #008000">/// Invoked when an item is clicked.</span><br><span style="color: #008000">/// </summary></span><br><span style="color: #008000">/// <param name="sender">The GridView (or ListView when the application is snapped)</span><br><span style="color: #008000">/// displaying the item clicked.</param></span><br><span style="color: #008000">/// <param name="e">Event data that describes the item clicked.</param></span><br><span style="color: #0000ff">void</span> ItemView_ItemClick(<span style="color: #0000ff">object</span> sender, ItemClickEventArgs e)<br>{<br>    var properties = <span style="color: #0000ff">new</span> Dictionary<<span style="color: #0000ff">string</span>, <span style="color: #0000ff">object</span>>() {{<span style="color: #006080">"Title"</span>, ((SampleDataGroup)e.ClickedItem).Title}};<br>    Microsoft.ApplicationInsights.Telemetry.WindowsStore.ClientAnalyticsChannel.Default.LogEvent(<span style="color: #006080">"Store/ItemView"</span>, properties);<br><br>    <span style="color: #008000">// Navigate to the appropriate destination page, configuring the new page</span><br>    <span style="color: #008000">// by passing required information as a navigation parameter</span><br>    var groupId = ((SampleDataGroup)e.ClickedItem).UniqueId;<br>    <span style="color: #0000ff">this</span>.Frame.Navigate(<span style="color: #0000ff">typeof</span>(SplitPage), groupId);<br>}

We are simple logging that the Item Click event was fired and logging the title of the group that was clicked. This when you click around in the sample app will log to Application Insights as you click around and generate some data. To see the features that were logged head over to Event Insights under the Features tab



It's really simple to get started with Application Insights and get that feedback from your application when it's out there in the wild.


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


About the Author

Gordon Beeming (RSA)
Software Developer Derivco
South Africa South Africa
Gordon Beeming is a Software Developer at Derivco in the sunny city of Durban, South Africa. He spends most his time hacking away at the keyboard in Visual Studio or with his family relaxing. He is a Visual Studio ALM Rangers, Visual Studio ALM MVP and Friend of Red Gate. His blog is at and you can follow him on Twitter at

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170118.1 | Last Updated 16 Apr 2014
Article Copyright 2014 by Gordon Beeming (RSA)
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid