Introduction

App Center is an awesome tool. Amongst other features it provides analytics for our application. Its dashboard is really simple and so, whether it is by habbit or because of its limited dashboard, mobile developers often tend to use tools like Firebase for their analytics.

While Firebase provides good dashboards by default it is sometimes still not enough. Furthermore, not every developer or company can have its analytics data stored inside Google’s or any other third party providers’ servers.

App Center is not designed to be a full fledged analytics portal. To get the most out of it we need to enter the wonderful world of Application Insights.

The purpose of this post is to show how to can use Application Insights to extract meaningful information from any mobile application, whatever it is using Xamarin or not.

Adding App Center

For this post I assume that you have a mobile application connected to App Center. If you need more informations on how to add App Center SDK into your application please refer to https://appcenter.ms.

Of course, to simplify things I have created a really simple Xamarin.Forms application consisting of three buttons.

  ...
  <Button Text="Red" Clicked="OnRedButtonClicked" />
  <Button Text="Green" Clicked="OnGreenButtonClicked" />
  <Button Text="Blue" Clicked="OnBlueButtonClicked" />
  ...
...
using Microsoft.AppCenter;
using Microsoft.AppCenter.Analytics;
...
public void OnRedButtonClicked(object sender, EventArgs e)
{
    Analytics.TrackEvent("Color", new Dictionary<string, string> { { "Value", "Red" } });
}

private void OnGreenButtonClicked(object sender, EventArgs e)
{
    Analytics.TrackEvent("Color", new Dictionary<string, string> { { "Value", "Green" } });
}

private void OnBlueButtonClicked(object sender, EventArgs e)
{
    Analytics.TrackEvent("Color", new Dictionary<string, string> { { "Value", "Blue" } });
}
...

When the user clicks on one of the buttons, it uses App Center SDK to send a Color event with the actual color value in the properties parameter of the TrackEvent method.

We can verify that we are sending the events correctly by going into App Center’s application dashboard. Under the Analytics section, select Events. Click on our event name and we should see something like the image below.

mobile-analytics-appcenter-event-details

Whether we are using Xamarin or not, as long as it is on iOS or Android, what is described in this post will work.

Exporting to Application Insights

We now need to configure the export:

  1. Go into the application settings
  2. Select Export
  3. Click on New export
  4. Export to Application Insights

Exporting to Blob Storage requires more work but is more customizable. For the sake of simplicity we stay with Application Insights here.

appcenter-data-export-config

We need to associate App Center with an Azure subscription to configure the data export:

  • If you already have, you can go directly to the configuring the exportation paragraph
  • If you did not, the following message will be displayed.

mobile-analytics-add-azure-subscription

Adding an Azure subscription

In the Azure section of App Center click on the + button as shown in the screenshot below.

mobile-analytics-manage-add-azure-subscription

You will be asked to log into your Azure account. Upon successful login click on Connect to finalize the association.

mobile-analytics-manage-associate-azure-subscription

The process redirects back to App Center with the subscription added.

mobile-analytics-manage-associate-azure-subscription-completed

Select the newly added subscription.

mobile-analytics-add-app-to-subscription

Add this subscription to the desired applications.

mobile-analytics-add-app-to-subscription-completed

Finally, with these steps completed we can configure the exportations by restarting the steps at the previous paragraph: Exporting to Application Insights

Configuring the exportation

  1. Set up the export
    • Set up standard export if you do not have any Application Insights instance in Azure.
    • Or click on Customize instead if you already have an instance.
  2. Click to Add to subscription

mobile-analytics-setup-export

Congratulations, set up is now complete !

mobile-analytics-setup-export-completed

Exporting to Azure does not happen in real time. You need to wait a few minutes before actually being able to work on the analytics you have.

Extracting data

If you have chosen the standard export you can go directly to Azure from App Center either by clicking on the View in Azure button in the Export section or by clicking on View in Application Insights in the Analytics section of the application.

mobile-analytics-appcenter-view-in-azure

mobile-analytics-appcenter-view-in-app-insights

In Application Insights you can look for every events by clicking on Search and query them by clicking on Logs.

mobile-analytics-app-insights-overview

Looking at the data

By clicking on Search we find the list of every events.

mobile-analytics-app-insights-event-list

We can of course see events details.

mobile-analytics-app-insights-event-list

Among the many interesting properties we see that the additional informations we sent are located into the Properties property of the event as a serialized Json object.

Query the data

By clicking on Logs we are presented an interface where we can type Kusto queries.

For more informations on Kusto please look at the official documentation.

Let’s enter of first request where we will look for every event named Color and we will count the number of times each color has been selected on the past day.

customEvents
| where timestamp >= ago(1d)
| where itemType == "customEvent"
| where name == "Color"
| extend Properties = todynamic(tostring(customDimensions.Properties))
| extend ColorValue = tostring(Properties.Value)
| summarize count(ColorValue) by ColorValue


By defaults results are shown as tabular data.

mobile-analytics-app-insights-log-analytics-tabular-result

But we can have a more graphical representation too.

mobile-analytics-app-insights-log-analytics-pie-result

Charts color or label are not configurable for now. Hopefully there is a better way and for this read until the end.

About Application Insights

Pricing

App Center is free for analytics. Application Insights as a pricing model that can be found here: https://azure.microsoft.com/en-us/pricing/details/monitor/

Data

Retention

By default, Application Insights has a data retention of 90 days. I highly suggest that you increase this value and that you consider exporting to a blob storage from Application Insights or from App Center as shown previously.

Property

By using App Center and Application Insights you keep the ownership of your data and you can choose how long you want to keep it, if not indefinitely.

Localisation

By using a custom set up of Application Insights, you can choose where you want your data to be stored. It is very important for applications that must comply with local rules like the GDPR in Europe.

Conclusion

Now that data is sent from App Center to Application Insights, we have a persistent storage and powerful quering capabilities on them. Furthermore, we keep the property of this data.

If your company is already using Azure you may already find people within your organization with Application Insights skills and therefore might find a way to have an even better use of it.

I recommend that you start writing a lot of queries to extract meaningful data from the usage of your application. queries written in Kusto can be used as well in a Power BI dashboards !

I guess that will be for the next article, please let me know on Twitter or in the comments below if you’d find it interesting.

As always, please feel free to read my previous posts and to comment below, I will be more than happy to answer.

Comments