Monitoring Microsoft Dynamics CRM / 365

Monitoring Microsoft Dynamics CRM / 365

The Dynamics 365 uses iframes intensively, this breaks most End-User-Monitor JavaScripts, because they uses the Browser Performance Timings, which are incorrect/misleading because the script is loaded inside a sub frame. The causes the measurements to be faster than actual time experienced by the user.


Dynamics 365 has built in performance metrics that can be used to troubleshoot and monitor performance. MCG UXM uses these metrics delivered by Dynamics 365.

The data can only be gathered if our custom UXM Web Dynamics 365 JavaScript is put in the top frame of the Dynamics 365 solution.


Ways to inject the JavaScript

  • On-Premise: Use IIS Module URL Rewrite to inject JavaScript into the Dynamics 365 main.aspx page.
    It's only possible if you host and have access to the Windows Server and IIS manager.

  • Cloud: JavaScript files can be injected into Forms, our monitoring script can be added and started the first time a user visits a form. 
    The user will be monitored from when he visits the form and until he closes/reopens his browser, reloads the page or opens new tab. (The JavaScript is running in the top window frame)

  • Both Cloud and On-Premise: The UXM Desktop agent can be installed on the visiting users PC's and can inject the JavaScript into the users browser, currently Internet Explorer  and Chrome is supported via Browser plugins.


What the UXM Web JavaScript does

  • It activates the PerformanceMarkers via Mscrm.Performance.PerformanceMarkerManager.get_instance().set_isEnabled(true). 
    (Use Mscrm.Performance.PerformanceCenter.get_instance().TogglePerformanceResultsVisibility() to see performance timings in the browser or press Ctrl+Q, note that the hot-key closes Chrome and Firefox)
  • Injectes code into the PerformanceMarkerManager to get announcements when markes are cleared. (Markers are cleared everytime the user leaves a form or dashboard)

  • It sends the data and calculates how long time each Dashboard and Form took when data is cleared.

  • Overhead is very low, Dynamics 365 already measures and calls the PerformanceMarkerManager when disabled, it just skips storing the metrics.

  • The UXM Web JavaScript also collects Latency and Bandwidth measurements, which Dynamics 365 performs every 1 hour.

Data collected

We collect the time it took to load the Form or Dashboard and the timings/events that occurred.
The data is then rolled up to a overview dashboard for Dynamics 365.

Using URL Rewrite

See Web Agent on IIS URL Rewrite for instructions on how to install and use the URL Rewrite module, the following script needs to be injected into the main.aspx page.


Injecting JavaScript via Form

Select a form or multiple forms that is used by many users. The UXM Web JavaScript will be injected when the user visits that form, and he will be monitor until he leave Dynamics or reloads the page.


Adding UXM Web JavaScript as an resource

Select Settings -> Customizations


 Select "Customize the System"


Select Web Resources and press New


Enter the following information in the popup:

  • Name: uxm_web_agent_dynamics_javascript
  • Display Name: UXM Web Agent - Dynamics 365 JavaScript
  • Description: JavaScript for monitoring end-users performance.
  • Type: Script (JScript)


Copy-paste the Dynamics 365 JavaScript from our download site: into the Text Editor popup box.

Update the reportingServer URL to the domain assigned to you.



Press OK and Save


The URL will then be filled out with a link you need when adding the JavaScript to forms.

Example url:


Publish the resource and close the popup window.


Adding JavaScript to forms

Open the form and press the Form link to edit it.


Press Form Properties to add JavaScript to the form.


Select Add under Form Libraries


Press New. (Note that Look for and Look in is locked if adding to Managed solution, so you will have to create 1 JavaScript resource per form. If it's a unmanaged solution you can reuse the same JavaScript resource)


Enter the following information in the popup and replace the form name with the form you are adding to:

  • Name: uxm_web_agent_dynamics_javascript_inject_into_account_form
  • Display Name: UXM Web Agent - Dynamics 365 JavaScript - Account Form
  • Description: JavaScript for monitoring end-users performance.
  • Type: Script (JScript)
  • Text Editor: Add following JavaScript to load the full JavaScript added as a resource above, please remember to replace the url "" with the URL generated in the steps above.
    (function (w, d, s, sn, on, ne, fse) {
    	if(w['McgUxmObj'] !== undefined) {
    		console.warn('UXM agent is already injected into top frame, skipping.');
    	w['McgUxmObj'] = on;
    	w[on] = w[on] || function () {(w[on].iargs = w[on].iargs || []).push(arguments)}, 
    	w[on].jsst = 1 * new Date();
    	ne = d.createElement(s), 
    	fse = d.getElementsByTagName(s)[0]; 
    	ne.async = 1; 
    	ne.src = sn; 
    	fse.parentNode.insertBefore(ne, fse)
    })(,, 'script', '//', 'uxm_web');


Press Save and Publish and close the form.

Press Add to add the JavaScript.


Press OK to close the Form Properties.

Press Save and then Publish and close the Form editor.


Validating JavaScript injection

Open the Inspector. (F12 in Chrome/Firefox/IE) and reload the Dynamics 365 form page, you will see the following console output.


If you look in the Inspector the script should be place in the top frame under that head segment.


Viewing forms JavaScript has been injected onto and removing it again

Select Settings -> Customizations


 Select "Customize the System"


Select Web Resources and set the following filter

  • Type: Script (JScript)
  • Name: Custom Filter... -> Contains 'uxm'



Open the _inject_info_x_form resource and press "Show Dependencies" to view where the resource has been added.

Note that you will have to remove the resource from the form and press Save/Publish on the form, before you can delete the resource.


Injecting via UXM Desktop Agent



Print Friendly and PDF
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request
Powered by Zendesk