Customize Real User Monitoring with the JavaScript API for web applications

Dynatrace enables you to extend its default Real User Monitoring functionality using the RUM JavaScript API. It allows you to create custom user actions, report errors, enable Session Replay, and much more.

The RUM JavaScript API comes included in the RUM JavaScript, which is injected automatically by OneAgent. If you haven't installed OneAgent, you can use agentless monitoring to insert the RUM JavaScript manually.

Capabilities

The RUM JavaScript API, which is called directly from your application code, offers lots of additional capabilities.

  • Create custom user actions
    If you want to monitor certain functionality of your application that Dynatrace doesn't capture automatically, you can define your own custom user actions.
    Suppose that you want to monitor a specific UI element that shows up in response to a user's click but doesn't trigger a web request. In such a case, Dynatrace won't consider this click a user action. With the RUM JavaScript API, you can still monitor such user interactions.

  • Define custom names for user actions
    You can use the RUM JavaScript API to define your own user action names and override the default naming behavior.

  • Report errors
    Sometimes there are errors that Dynatrace cannot recognize by default. You can use the RUM JavaScript API error reporting functionality to report errors, which then show up in the Errors section of the application overview page.

  • Add and extend third-party monitoring
    When the resource timing module is active, all resources from the resource timings are captured. Images and JavaScript files are captured with a third-party module. You can use the RUM JavaScript API to capture additional resources.

  • Add user tags
    With user tags, you can track the user behavior of specific users throughout your application environment and across sessions, devices, and browsers.

  • Report properties
    You can use the RUM JavaScript API to report session and user action properties. Note that you first need to define session and user action properties within the RUM application settings. Otherwise, Dynatrace will discard submitted properties.

  • Enable or disable Session Replay
    Using the RUM JavaScript API, you can enable or disable the Session Replay feature.

  • Report business events
    Besides reporting simple events that are part of a user action, you can also report complex data-packed business events. For more details, see Business Analytics.

Documentation

The RUM JavaScript API documentation provides information on all RUM customization options and also contains useful code samples. You can either access the JavaScript API documentation online or download a ZIP archive from your environment to view the guide offline.

Difference between RUM JavaScript APIs

Note that Dynatrace provides two APIs related to Dynatrace Real User Monitoring.

  • The RUM JavaScript API, which is explained in this topic, is designed to extend out-of-the-box features of Real User Monitoring for your application.
  • The RUM JavaScript REST API is often used to get the most recent RUM JavaScript for agentless RUM. You must then manually insert the RUM JavaScript tag or code into each HTML page of your application. With this API, you can also obtain a list of all manually inserted applications in your environment and verify the most recent version of the RUM JavaScript.