How does real user monitoring injection work?

Dynatrace real user monitoring (RUM) collects metrics from your customers' web browsers and correlates the browser data with server-side information obtained from Dynatrace OneAgent. Web browser data is collected by a JavaScript tag that is placed inside the HTML of your applications' web pages. We call this JavaScript tag placement an "injection."

How does JavaScript injection work?

You can initiate Dynatrace JavaScript tag injection in one of two ways:

  • Dynatrace OneAgent JavaScript tag injection is performed automatically during installation for Java, Apache HTTP Server, IIS and Node.js. All you need to do to initiate injection is to restart your web server processes after Dynatrace OneAgent installation. Dynatrace OneAgent identifies HTML content responses and automatically injects a small JavaScript tag into the head section of each page.
  • You can alternatively inject the JavaScript tag into HTML code manually without installing Dynatrace OneAgent. We provide the JavaScript tag for you during the set up process. You can paste the tag into the pages you intend to monitor.
    You can define a custom location for tag injection by adjusting application settings. You can, for example, tell Dynatrace to inject the tag before or after a defined string in an HTML response. In the case of Java you can specify injection within the innermost or outermost HttpServletResponse, within a custom servlet, or within a filter.

To access custom injection settings:

  1. Click the Applications tile on your home dashboard.
  2. Select the application you want to configure.
  3. Click Edit on the menu bar.
  4. Click Advanced setup.
  5. Click JavaScript injection.

For more information see, How do I enable real user monitoring?

Depending on how you enable RUM, monitoring data is sent to Dynatrace within varying request types:

  • If you have Dynatrace OneAgent installed:
    Our JavaScript sends data back to your web server (Java, Apache, IIS). Dynatrace OneAgent performs some initial monitoring of the data and then forwards it to Dynatrace Server. Transmission of data is performed using XHR Post requests.
  • If you don't have Dynatrace OneAgent installed:
    Data is sent directly to Dynatrace, bypassing your infrastructure.

Where is the JavaScript tag injected?

First of all, Dynatrace JavaScript only works with valid HTML. Messy page code is often the culprit when monitoring-data flow breaks down. So please pay special attention to basic HTML best practices (i.e., no unclosed or missing tags).

Our JavaScript tag is injected only into HTML. We don't modify images, CSS, REST services, or XML files. Dynatrace OneAgent always tries to inject the JavaScript tag as the first script on the page. This helps to keep your application intact but also guarantees more reliable monitoring results (for example, timing). If you inject the JavaScript tag manually, ensure that it's the first executable script on each page.

If Dynatrace OneAgent doesn't automatically inject the JavaScript tag because of HTML validation errors, you can add a custom monitoring rule. For information about accessing custom injection settings, see the instructions detailed above.

Not sure that real user monitoring is working in your environment? Having trouble with your setup? Have a look at How can I verify that real user monitoring is working?