Application Insight to get Popular Pages even if Multiple ids in URL
Posted on: October 18, 2016
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.
1pageViews2 | extend replaced_operation_ParentName = replace(@'(\\d+)', @'x', operation_Name)3 | where timestamp >= ago(7d)4 | summarize c = count(replaced_operation_ParentName)5 by replaced_operation_ParentName6 | where c > 17 | 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.