Select a snippet format in the New RUM Experience

  • Latest Dynatrace
  • How-to guide
  • Published Oct 29, 2025
  • Preview

The RUM JavaScript—whether automatically injected or manually inserted into your web application—consists of two key components:

  • Monitoring code: The JavaScript code that provides RUM capabilities such as capturing user events.
  • Configuration: The application configuration that is initially used by the monitoring code. It is updated later via the RUM beacon response in case of configuration changes.

The New RUM Experience provides several snippet formats that integrate these components into your pages in different ways, each tailored to meet specific requirements.

This page offers guidance to help you choose the snippet format that best meets your requirements, followed by a detailed description of each format.

Recommendations for selecting the snippet format

For most use cases, we recommend the following:

If you want to leverage the subresource integrity (SRI) browser feature to ensure that the monitoring code hasn't been altered, use OneAgent JavaScript tag with SRI for manual insertion and automatic injection.

To avoid parse-blocking execution of the monitoring code, configure the script execution option of your selected snippet format to async or defer. Instructions for configuring this option are provided in the documentation for each individual snippet format below. Keep in mind that while the monitoring code is not yet fully loaded and initialized, certain timings and user events will be lost.

Available snippet formats

Below, you'll find all snippet formats available in the New RUM Experience, along with their configuration options. Note that both the New RUM Experience and RUM Classic use the same RUM JavaScript snippet. When the New RUM Experience is enabled, the monitoring code includes additional modules, and the snippet contains extended configuration. However, the underlying snippet remains shared. As a result, any changes you make to the settings described below for the New RUM Experience also apply to RUM Classic.

JavaScript tag links to an external file that includes both the monitoring code and the configuration. JavaScript tag is only available for manual insertion.

Updates

The short cache duration used for the external file ensures regular automatic updates, making JavaScript tag an ideal choice if you don't want to take care of updating the inserted snippet after configuration changes.

Monitoring code source

The external file is loaded from the Dynatrace CDN.

Cache duration

The external file containing monitoring code and configuration is updated according to its cache duration, which is one hour by default and can be configured. The available values are low—a few hours or days—to ensure the configuration is updated regularly. The cache duration specifies how long browsers can cache the file. The Dynatrace CDN caches it for one hour.

To configure the cache duration

  1. Go to Experience Vitals Experience Vitals.
  2. Select Web to view all web frontends.
  3. Select the frontend you want to configure.
  4. On the Settings tab, select Manual insertion.
  5. In the JavaScript tag section, use the dropdown under Cache monitoring code and configuration for to select the required cache duration.
Script execution

By default, the monitoring code is loaded and executed synchronously by the browser. To avoid parse-blocking behavior, you can configure the addition of the async or defer attributes.

  • With the async attribute, the monitoring code is loaded in parallel with page parsing and executed immediately once it’s available.
  • With the defer attribute, the monitoring code is also loaded in parallel, but execution is deferred until after the page has finished parsing.

With both attributes, certain timings and user events will be lost while the monitoring code is not yet fully loaded and initialized.

To configure script execution

  1. Go to Experience Vitals Experience Vitals.
  2. Select Web to view all web frontends.
  3. Select the frontend you want to configure.
  4. On the Settings tab, select Manual insertion.
  5. In the JavaScript tag section, set Script execution attribute to async, defer, or No attribute.
  6. Copy the snippet and insert it into your page.

When fetching the JavaScript tag via the API, you can control script execution by passing a parameter. For details, see GET JavaScript tag.

Addition of the crossorigin="anonymous" attribute

🟢 Enabled by default

The external script referenced by JavaScript tag is served from the Dynatrace CDN, resulting in a cross-origin request. To enable the collection of detailed JavaScript error messages and W3C resource timings, you need to include the crossorigin="anonymous" attribute in the script tag.

To enable the addition of the crossorigin="anonymous" attribute

  1. Go to Experience Vitals Experience Vitals.
  2. Select Web to view all web frontends.
  3. Select the frontend you want to configure.
  4. On the Settings tab, select Manual insertion.
  5. In the JavaScript tag section, enable Add crossorigin=anonymous attribute.
  6. Copy the snippet and insert it into your page.

When fetching the JavaScript tag via the API, you can control the addition of the crossorigin="anonymous" attribute by passing a parameter. For details, see GET JavaScript tag.

Related tags
Digital Experience