title: Usage analysis with Azure Application Insights | Microsoft docs description: Understand your users and what they do with your app. services: application-insights documentationcenter: '' author: botatoes manager: carmonm
ms.service: application-insights ms.workload: tbd ms.tgt_pltfrm: ibiza ms.devlang: multiple ms.topic: article ms.date: 10/10/2017 ms.author: mbullwin
Which features of your web or mobile app are most popular? Do your users achieve their goals with your app? Do they drop out at particular points, and do they return later? Azure Application Insights helps you gain powerful insights into how people use your app. Every time you update your app, you can assess how well it works for users. With this knowledge, you can make data driven decisions about your next development cycles.
The best experience is obtained by installing Application Insights both in your app server code, and in your web pages. The client and server components of your app send telemetry back to the Azure portal for analysis.
-
Server code: Install the appropriate module for your ASP.NET, Azure, Java, Node.js, or other app.
- Don't want to install server code? Just create an Azure Application Insights resource.
-
Web page code: Open the Azure portal, open the Application Insights resource for your app, and then open Getting Started > Monitor and Diagnose Client-Side.
-
Mobile app code: Use the App Center SDK to collect events from your app, then send copies of these events to Application Insights for analysis by following this guide.
-
Get telemetry: Run your project in debug mode for a few minutes, and then look for results in the Overview blade in Application Insights.
Publish your app to monitor your app's performance and find out what your users are doing with your app.
To track users over time, Application Insights requires a way to identify them. The Events tool is the only Usage tool that does not require a user ID or a session ID.
Start sending user and session IDs using this process.
Find out when people use your app, what pages they're most interested in, where your users are located, what browsers and operating systems they use.
The Users and Sessions reports filter your data by pages or custom events, and segment them by properties such as location, environment, and page. You can also add your own filters.
Insights on the right point out interesting patterns in the set of data.
- The Users report counts the numbers of unique users that access your pages within your chosen time periods. For web apps, users are counted by using cookies. If someone accesses your site with different browsers or client machines, or clears their cookies, then they will be counted more than once.
- The Sessions report counts the number of user sessions that access your site. A session is a period of activity by a user, terminated by a period of inactivity of more than half an hour.
More about the Users, Sessions, and Events tools
From the Usage blade, click through the Page Views tile to get a breakdown of your most popular pages:
The example above is from a games web site. From the charts, we can instantly see:
- Usage hasn't improved in the past week. Maybe we should think about search engine optimization?
- Tennis is the most popular game page. Let's focus on further improvements to this page.
- On average, users visit the Tennis page about three times per week. (There are about three times more sessions than users.)
- Most users visit the site during the U.S. working week, and in working hours. Perhaps we should provide a "quick hide" button on the web page.
- The annotations on the chart show when new versions of the website were deployed. None of the recent deployments had a noticeable effect on usage.
What if you want to investigate the traffic to your site in more detail, like splitting by a custom property your site sends in its page view telemetry?
- Open the Events tool in the Application Insights resource menu. This tool lets you analyze how many page views and custom events were sent from your app, based on a variety of filtering, cohorting, and segmentation options.
- In the "Who used" dropdown, select "Any Page View".
- In the "Split by" dropdown, select a property by which to split your page view telemetry.
Retention helps you understand how often your users return to use their app, based on cohorts of users that performed some business action during a certain time bucket.
- Understand what specific features cause users to come back more than others
- Form hypotheses based on real user data
- Determine whether retention is a problem in your product
The retention controls on top allow you to define specific events and time range to calculate retention. The graph in the middle gives a visual representation of the overall retention percentage by the time range specified. The graph on the bottom represents individual retention in a given time period. This level of detail allows you to understand what your users are doing and what might affect returning users on a more detailed granularity.
To get a clear understanding of what users do with your app, it's useful to insert lines of code to log custom events. These events can track anything from detailed user actions such as clicking specific buttons, to more significant business events such as making a purchase or winning a game.
Although in some cases, page views can represent useful events, it isn't true in general. A user can open a product page without buying the product.
With specific business events, you can chart your users' progress through your site. You can find out their preferences for different options, and where they drop out or have difficulties. With this knowledge, you can make informed decisions about the priorities in your development backlog.
Events can be logged from the client side of the app:
appInsights.trackEvent("ExpandDetailTab", {DetailTab: tabName});
Or from the server side:
var tc = new Microsoft.ApplicationInsights.TelemetryClient();
tc.TrackEvent("CreatedAccount", new Dictionary<string,string> {"AccountType":account.Type}, null);
...
tc.TrackEvent("AddedItemToCart", new Dictionary<string,string> {"Item":item.Name}, null);
...
tc.TrackEvent("CompletedPurchase");
You can attach property values to these events, so that you can filter or split the events when you inspect them in the portal. In addition, a standard set of properties is attached to each event, such as anonymous user ID, which allows you to trace the sequence of activities of an individual user.
Learn more about custom events and properties.
In the Users, Sessions, and Events tools, you can slice and dice custom events by user, event name, and properties.
When you are designing each feature of your app, consider how you are going to measure its success with your users. Decide what business events you need to record, and code the tracking calls for those events into your app from the start.
If you don't know which variant of a feature will be more successful, release both of them, making each accessible to different users. Measure the success of each, and then move to a unified version.
For this technique, you attach distinct property values to all the telemetry that is sent by each version of your app. You can do that by defining properties in the active TelemetryContext. These default properties are added to every telemetry message that the application sends - not just your custom messages, but the standard telemetry as well.
In the Application Insights portal, filter and split your data on the property values, so as to compare the different versions.
To do this, set up a telemetry initializer:
// Telemetry initializer class
public class MyTelemetryInitializer : ITelemetryInitializer
{
public void Initialize (ITelemetry telemetry)
{
telemetry.Properties["AppVersion"] = "v2.1";
}
}
In the web app initializer such as Global.asax.cs:
protected void Application_Start()
{
// ...
TelemetryConfiguration.Active.TelemetryInitializers
.Add(new MyTelemetryInitializer());
}
All new TelemetryClients automatically add the property value you specify. Individual telemetry events can override the default values.