DESK 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 DESK 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.
You can define a custom location for tag injection by adjusting application settings. You can, for example, tell DESK 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
- Click Applications from the navigation menu.
- Select the application you want to configure.
- Click the browse button (...) and select Edit.
- Click Advanced setup.
- Click JavaScript injection on the right hand-side.
Depending on how you enable RUM, monitoring data is sent to DESK 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 DESK server. Transmission of data is performed using XHR Post requests.
- If you don't have OneAgent installed:
Data is sent directly to DESK, bypassing your infrastructure.
Where is the JavaScript tag injected?
The DESK 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.
Click to view the table of rules
Note: Rules names appear in the OneAgent log in the following format: (NAME rule)
, for example (</head> tag rule)
.
Name |
Condition |
Action |
Overrules |
<!DOCTYPE> |
The <!DOCTYPE> tag is not <!DOCTYPE html> . |
Abort and do not inject. |
|
initial tag |
A tag appears before <html> that is not one of the following:
<!DOCTYPE ...>
<html>
<link>
<meta>
<script>
<style>
|
Abort without injecting. |
|
<?xml?> |
an <?xml ...?> specification is encountered. |
Ignore and continue to scan the document. |
non-<meta> tag
non-<head> tag
initial tag
|
<html> tag |
The <html> tag is encountered. |
If a potential injection point is found earlier, inject there, and do not scan further. If there are multiple potential injection points, the earliest one is used.
Otherwise continue to scan the document
|
|
<script src> tag |
A <script src="..."> tag is found within <head> . |
If a potential injection point is found earlier, inject there, and do not scan further. If there are multiple potential injection points, the earliest one is used.
Otherwise, inject before this <script> tag and do not scan further.
|
non-<meta> tag
<base>/<meta> tag
|
<title>/<noscript> tag |
The <title> or the <noscript> tag is encountered. |
Ignore everything until the </title> or the </noscript> tag, then continue to scan the document. |
<body> tag |
<base>/<meta> tag |
Either the <base> or the <meta> tag is encountered. |
Discard any conditional injection point found earlier. Continue to scan the document. |
any conditional injection point found earlier by:
non-<meta> tag
unclosed <meta>
non-<head> tag
|
non-<meta> tag |
A tag is found within <head> that is neither <meta> nor <title> . |
Inject before it (conditional injection).
Continue to scan the document, in case this injection choice is overruled.
|
|
unclosed <meta> |
The </head> tag arrives after a <meta> tag that isn't closed either by the closing </meta> tag or by the XML-style <meta ... /> tag. |
Add </meta> followed by the injection, both before the </head> (conditional injection).
Continue to scan the document, in case this injection choice is overruled.
|
|
comment |
The <!- comment -> tag is encountered. |
Ignore and continue to scan the document. |
non-<meta> tag
non-<head> tag
|
non-<head> tag |
A tag is found after <html> but before <head> that is neither <head> nor <body> . |
Inject before it (conditional injection).
Continue to scan the document, in case this injection choice isoverruled.
|
|
</head> tag |
The </head> tag encountered. |
If a potential injection point is found earlier, inject there, and do not scan further. If there are multiple potential injection points, the earliest is used
Otherwise, continue to scan the document.
|
|
flush |
Java only
Flush is called on the injecting stream/writer outside of the <head></head> section and a conditional injection awaits confirmation.
|
Discard the conditional injection point, propagate the flush,and continue to scan the document for a new injection point. |
any conditional injection point found before by:
non-<head> tag
|
flush in <head> |
Java only
Flush is called on the injecting stream/writer inside <head></head> and conditional injection awaits confirmation.
|
Keep the injection point and continue to scan the document.
Disregard the flush.
|
|
<body> tag |
The <body> tag is encountered. |
Document scan stops. Any potential injection point found earlier is used. If there are multiples potential injection points, the earliest one is used
If no rule matched earlier, inject after the <body> .
|
|
end of file |
End of file is reached and scanning didn't terminate before that. |
Don't perform an injection. |
any conditional injection point found before by:
non-<meta> tag
unclosed <meta>
non-<head tag
|
parse error |
The document's contents don't appear to exhibit the basic structure expected from HTML tags and attributes |
Document scan stops.
If a potential injection point is found earlier, inject there, and do not scan further. If there are multiple potential injection points, the earliest one is used.
If no rule provides an earlier injection point, don't perform an injection
|
|
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?
What about older internet browsers?
For an older internet browsers (Internet Explorer and legacy versions other browsers) interacting with massive DOMs and Visually Complete metric enabled, we recommend to use additional parameter vcfi=0 (Application settings - Capturing - Advanced setup - Custom configuration properties), which provide carefully handling of images.