Patrick Desjardins Blog
Patrick Desjardins picture from a conference

Application Insight to get Popular Pages even if Multiple ids in URL

Posted on: 2016-10-18

Application Insight is very powerful system that let you collect telemetry on your website. It's a service on Azure, which is currently free with the limitation to keep data for 7 days and aggregated data for 90 days.

One interesting thing you can do, without having to configure anything else than using Application Insight with your website, is to query the pageViews table. It allows you to get information about each page requested by user. However, if you are using an application you may have url with ID. For example http://yourwebsite.com/user/12345/data/group/567/. The problem is that you will get result with noise. The same page has variables in the url. A simple fix is to replace any integer. Here is a code you can use on your own data which replace integer with a 'x' character.

 pageViews 
  | extend replaced_operation_ParentName = replace(@'(\\d+)', @'x', operation_Name) 
  | where timestamp >= ago(7d) 
  | summarize c = count(replaced_operation_ParentName) 
      by replaced_operation_ParentName 
  | where c > 1 
  | order by c desc 

The result look like this:

This is pretty fast, with less than 1 sec I got all the result. If you are not using integer in your url, but Guid, you can change the Regex to replace the pattern of a Guid.