Getting started
New announcements from Dash: Incident Management, Continuous Profiler, and more! New announcements from Dash!

Getting started

To set up Datadog Real User Monitoring solution:

  1. On the Real User Monitoring page, click the New Application button.
  2. Fill out Application Details, and click Generate Client Token. This automatically creates a clientToken and an applicationId for your application.
  3. Setup the Datadog RUM SDK through npm or paste the generated code snippet into the head tag.
  4. Deploy the changes to your application. Once your deployment is live, Datadog starts collecting events from your user’s browsers.
  5. Visualize the data collected in Datadog out of the box Dashboards.

Note: Your application shows up on the application list page as “pending” until Datadog starts receiving data.

npm Setup

After adding @datadog/browser-rum to your package.json file, initialize it with:

import { datadogRum } from '@datadog/browser-rum';

datadogRum.init({
    applicationId: '<DATADOG_APPLICATION_ID>',
    clientToken: '<DATADOG_CLIENT_TOKEN>',
    site: 'datadoghq.com',
//  service: 'my-web-application',
//  env: 'production',
//  version: '1.0.0',
    sampleRate: 100,
    trackInteractions:true,
});
import { datadogRum } from '@datadog/browser-rum';

datadogRum.init({
    applicationId: '<DATADOG_APPLICATION_ID>',
    clientToken: '<DATADOG_CLIENT_TOKEN>',
    site: 'datadoghq.eu',
//  service: 'my-web-application',
//  env: 'production',
//  version: '1.0.0',
    sampleRate: 100,
    trackInteractions:true,
});

Note: The trackInteractions initialization parameter enables the automatic collection of user clicks in your application. Sensitive and private data contained on your pages may be included to identify the elements interacted with.

Bundle Setup

Paste the generated code snippet into the head tag (in front of any other script tags) of every HTML page you want to monitor in your application. Including the script tag higher and synchronized ensures Datadog RUM can collect all performance data and errors.

<script
    src="https://www.datadoghq-browser-agent.com/datadog-rum.js"
    type="text/javascript"
></script>
<script>
    window.DD_RUM &&
        window.DD_RUM.init({
            clientToken: '<CLIENT_TOKEN>',
            applicationId: '<APPLICATION_ID>',
            site: 'datadoghq.com',
        //  service: 'my-web-application',
        //  env: 'production',
        //  version: '1.0.0',
            sampleRate: 100,
            trackInteractions:true,
        });
</script>
<script
    src="https://www.datadoghq-browser-agent.com/datadog-rum.js"
    type="text/javascript"
></script>
<script>
    window.DD_RUM &&
        window.DD_RUM.init({
            clientToken: '<CLIENT_TOKEN>',
            applicationId: '<APPLICATION_ID>',
            site: 'datadoghq.eu',
        //  service: 'my-web-application',
        //  env: 'production',
        //  version: '1.0.0',
            sampleRate: 100,
            trackInteractions:true,
        });
</script>

Note: The trackInteractions initialization parameter enables the automatic collection of user clicks in your application. Sensitive and private data contained on your pages may be included to identify the elements interacted with.

Note: The window.DD_RUM check is used to prevent issues if a loading failure occurs with the RUM SDK.

Initialization parameters

ParameterTypeRequiredDefaultDescription
applicationIdStringYes``The RUM application ID.
clientTokenStringYes``A Datadog Client Token.
siteStringYesdatadoghq.comThe Datadog Site of your organization. datadoghq.com for Datadog US site, datadoghq.eu for Datadog EU site.
serviceStringNo``The service name for this application.
envStringNo``The application’s environment e.g. prod, pre-prod, staging.
versionStringNo``The application’s version e.g. 1.2.3, 6c44da20, 2020.02.13.
trackInteractionsBooleanNofalseEnables automatic collection of Users Actions
resourceSampleRateNumberNo100Percentage of tracked sessions with resources collection. 100 for all, 0 for none of them.
sampleRateNumberNo100Percentage of sessions to track. Only tracked sessions send rum events. 100 for all, 0 for none of them.
silentMultipleInitBooleanNofalseInitialization fails silently if Datadog’s RUM is already initialized on the page
proxyHostStringNo``Optional proxy URL. See the full proxy setup guide for more information.
trackSessionAcrossSubdomainsBooleanNofalseSet to true to preserve session across subdomains of the same site. If you use both Logs and RUM SDKs, this config must match.
useSecureSessionCookieBooleanNofalseSet to true to use a secure session cookie. This will prevent RUM events from sending on insecure (non-HTTPS) connections. If you use both Logs and RUM SDKs, this config must match.
useCrossSiteSessionCookieBooleanNofalseSet to true to use a secure cross-site session cookie. This will allow the RUM SDK to run when the site is loaded from another one (for example, in an iframe). Implies useSecureSessionCookie. If you use both Logs and RUM SDKs, this config must match.

Further Reading