RUM JavaScript injection

Dynatrace Real User Monitoring (RUM) collects metrics from your customers' web browsers and correlates the browser data with server-side information obtained from 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:

  • OneAgent JavaScript tag injection is performed automatically during installation for Java, Apache HTTP Server, IIS, NGINX, and Node.js. All you need to do to initiate injection is to restart your web server processes after OneAgent installation. 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 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.

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

  • If you have OneAgent installed:
    Our JavaScript sends data back to your web server (Java, Apache, IIS). 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 OneAgent installed:
    Data is sent directly to Dynatrace, bypassing your infrastructure.

Where is the JavaScript tag injected?

The Dynatrace JavaScript only works with valid HTML. Messy page code is often the culprit when monitoring-data flow breaks down. So 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. 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.

The following rules specify the criteria for determining a suitable location within an HTML document to inject the JavaScript tag.

If 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 Why don't I see my applications or monitoring data?