Click here to Skip to main content
13,139,254 members (86,610 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


1 bookmarked
Posted 18 Feb 2014

Using Application Insights with an Existing Windows Store App

, 18 Feb 2014
Rate this:
Please Sign up or sign in to vote.
How to use Application Insights with an existing Windows Store app

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 a new Windows Store App for an example of adding Application Insights from the creation of a new project.

Installing Application Insights from NuGet

To add Application Insights to your project, install the Application Insights Telemetry SDK for Windows Store Apps (Id: Microsoft.ApplicationInsights.Telemetry.WindowsStore).

Install through the Manage NuGet Packages.


or using Package Manger Console:


The Application Insights NuGet package is now installed in your application.

Getting your Instrumentation Key

Navigate to a dashboard on VSO and click the admin/settings button in the top right and then click on Keys & Downloads, or browse to Select the application you are wanting to collect usage data for...


...and then navigate down to the Windows 8.1 Store SDK section and you will see your instrumentation key.


From here on, it's the same as if you started with a clean application and opted to install Application Insights with the start of your application.

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:

("the instrumentation key from VSO");

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

My existing application happens to be an empty Split Page application so 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:

/// <summary>
/// Invoked when an item is clicked.
/// </summary>
/// <param name="sender">The GridView (or ListView when the application is snapped)
/// displaying the item clicked.</param>
/// <param name="e">Event data that describes the item clicked.</param>
void ItemView_ItemClick(object sender, ItemClickEventArgs e)
    var properties = new Dictionary<string, object>() 
    {{"Title", ((SampleDataGroup)e.ClickedItem).Title}};
    ("Store/ItemView", properties);

    // Navigate to the appropriate destination page, configuring the new page
    // by passing required information as a navigation parameter
    var groupId = ((SampleDataGroup)e.ClickedItem).UniqueId;
    this.Frame.Navigate(typeof(SplitPage), groupId);

We are simply 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 Nologo Studios
South Africa South Africa
Gordon Beeming works at Nologo Studios in the sunny city of Durban, South Africa. His current focus is on Devloper Efficiencies and R&D. When he's not hacking away at a keyboard in Visual Studio he'll generally be relaxing with his family or hitting the black top getting in some mileage. He is a Visual Studio ALM Rangers, Visual Studio ALM MVP.

You may also be interested in...


Comments and Discussions

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