Azure Application Insights(AI) and capturing Dynamics 365 client side telemetry

What is Application Insights?

Application Insights is an extensible Application Performance Management (APM) service for web developers on multiple platforms. Use it to monitor your live web application. It allow you to monitor the end user performance of an application. It will automatically detect performance anomalies. It includes powerful analytics tools to help you diagnose issues and to understand what users actually do with your app. It's designed to help you continuously improve performance and usability. It works for apps on a wide variety of platforms including .NET, Node.js and J2EE, hosted on-premises or in the cloud. It integrates with your DevOps process, and has connection points to a variety of development tools. It can monitor and analyze telemetry from mobile apps by integrating with Visual Studio App Center.

In the past, performance monitoring was more about monitoring servers and their performance. It’s very easy to track the CRM form client-side performance using Application Insights. The Application Insight is not expensive, the basic plan is free and 1 GB of data is included every month.

What does Application Insights monitor?
  1. Request rates, response times, and failure rates 
  2. Dependency rates, response times, and failure rates 
  3. Exceptions
  4. AJAX calls from web pages
  5. User and session counts.
  6. Performance counters from your Windows or Linux server machines
  7. Host diagnostics from Docker or Azure.
  8. Diagnostic trace logs from your app
  9. Custom events and metrics that you write yourself in the client or server code, to track business events

Follow the below steps to configure the Application Insights for Dynamics 365,

  1. Create an Application Insights in the Azure portal.
  2. Open the Application Insights and Click on the Getting started under the Configure menu and then click on the Monitor and Diagnose Client Side Application.

  1. In the Client application monitoring and diagnosis form, copy the instrumentation key and paste it in a notepad file.

  1. Log in to Dynamics 365 and create a web resource for Application Insights and add the below-mentioned scripts. Update your Application Insights Instrumentation key in the highlighted area on the script.
if (ApplicationInsights === "undefined") {
 var ApplicationInsights = {};

ApplicationInsights = {
 trackApplicationInsight: function (entityName, properties) {
 var appInsights = window.appInsights || function (config) { function i(config) { t[config] = function () { var i = arguments; t.queue.push(function () { t[config].apply(t, i) }) } } var t = { config: config }, u = document, e = window, o = "script", s = "AuthenticatedUserContext", h = "start", c = "stop", l = "Track", a = l + "Event", v = l + "Page", y = u.createElement(o), r, f; y.src = config.url || ""; u.getElementsByTagName(o)[0].parentNode.appendChild(y); try { t.cookie = u.cookie } catch (p) { } for (t.queue = [], t.version = "1.0", r = ["Event", "Exception", "Metric", "PageView", "Trace", "Dependency"]; r.length;) i("track" + r.pop()); return i("set" + s), i("clear" + s), i(h + a), i(c + a), i(h + v), i(c + v), i("flush"), config.disableExceptionTracking || (r = "onerror", i("_" + r), f = e[r], e[r] = function (config, i, u, e, o) { var s = f && f(config, i, u, e, o); return s !== !0 && t["_" + r](config, i, u, e, o), s }), t }(
 window.appInsights = appInsights;

appInsights.trackPageView(entityName, Xrm.Page.context.getClientUrl(), properties);
  1. For whichever entity the performance telemetry needs to be captured add the below JavaScript code to the entity JavaScript web resource.
function accountOnLoad()
 var operationType = '';
 if (Xrm.Page.ui.getFormType() == 1) { operationType = 'Create'; } else { operationType = 'Update'; }

var properties = { User: Xrm.Page.context.getUserName(), ObjectId:, OperationType: operationType, TriggerEvent: 'Form Load' };
 ApplicationInsights.trackApplicationInsight('Account', properties);

function accountOnSave()
 var operationType = '';
 if (Xrm.Page.ui.getFormType() == 1) { operationType = 'Create'; } else { operationType = 'Update'; }

var properties = { User: Xrm.Page.context.getUserName(), ObjectId:, OperationType: operationType, TriggerEvent: 'Form Save' };
 ApplicationInsights.trackApplicationInsight('Account', properties);
  1. Add the created Application Insights web resource to the Entity Form Properties and add the JavaScript function to the form on-load and on-save event, so that the complete performance metrics will be captured by the Application Insights for these.


  1. You can add as much as details you want to capture by adding to the properties. These properties information will be captured as custom data in the Application Insights.
var properties = { User: Xrm.Page.context.getUserName(), ObjectId:, OperationType: operationType, TriggerEvent: 'Form Save' };  
ApplicationInsights.trackApplicationInsight('Account', properties);

  1. Now the client side performance telemetry will be captured on the on-load and on-save of the entity form. This function can be added to any events like button click, business process stage change, etc to capture the client side performance and exceptions
  1. Application Insights has lots of out of the box dashboards, charts and live metrices stream to monitor the metrices easily.


Posted: Sep 22, 2018,
Comments: 0,
Author: Urish Arora
Rate this article:

Urish AroraUrish Arora

Other posts by Urish Arora

, Contact author

Please login or register to post comments.




Subscribe to our blog

«November 2019»

  • Featured Posts
  • Recent Posts
  • Recent Comments
Dynamics365Authority is a community platform for Professionals and Students to contribute or share their knowledge and skills on Microsoft Dynamics 365 Technologies. Our primary goal is to invite professionals on Dynamics 365 technology across the world to contribute & share their knowledge and skills through their blogs so that we can help other developers.
Stay updated with Dynamics 365 technology. Improve skills and knowledge from our blogs, articles and code snippets. Learn it. Follow professionals and learn from them.
Unified Service Desk Book(Online Edition) 


Stay connected with us on our social media channels for latest articles, blogs posts etc.  We will keep updating regularly on our social media platform and web platform.


Follow us on Facebook



View all our tweets



Join us now



View our blogs



Latest Blog

Posted: Jun 20, 2019

Overview - Appendix (Unified Service Desk)

This blog is about Appendix

Read more
Posted: Jun 20, 2019

Overview - Troubleshoot and Debug (Unified Service Desk)

This blog is about Troubleshoot and Debug in Unified Service Desk

Read more
Posted: Jun 20, 2019

Overview - Performance (Unified Service Desk)

This blog is about the Performance in Unified Service Desk

Read more


Dynamics 365 - Search the library for "Dynamics 365"

  What's New in Dynamics 365

  Dynamics 365 Documentation


  Sign-up for 30 days trial



Recent comments


Nice blog. Very helpful to get all references to white papers at one place.

Previous Next

About Us

Here comes the Dynamics 365 Authority - Great technical blog posts are hidden gems. They are hard to find simply because not enough of us write them in the first place. Yet technical blogging is one of the best things we can do not only for ourselves, but also as members of the wider community of developers.

Dynamics 365 Authority leverages this platform to help developers and users to move from traditional paper-based process to modern digital business process. helps your business grow, evolve and transform. is your Digital Transformation Partner

Recent Posts

Overview - Appendix (Unified Service Desk)

This blog is about Appendix
  • 244
  • Article rating: 5.0

Overview - Troubleshoot and Debug (Unified Service Desk)

This blog is about Troubleshoot and Debug in Unified Service Desk
  • 372
  • Article rating: 5.0

Get in touch

Follow Us


Tag cloud: with Urish Arora;; Sales; Leading community site on MS Dynamics 365; Dynamics 365 Authority; Service;Top CRM Blogs; Urish Arora - Australia's leading expert on Digital Transformation;  Digital Transformation; Field Service;Top Articles on MS Dynamics CRM Relationship Insights; Office 365 Security Compliance; Project Service; Microsoft Dynamics 365 for Sales; Relevance Search; Goal Metrics; Activities and Case; Sales Literature;Knowledge Management;

Terms Of UsePrivacy StatementCopyright 2019 by Dynamics365Authority
Back To Top