RUM community plugins

A personal community project under @kyletaylored, MIT licensed.Not provided or supported by Datadog.

← All plugins

OneTrust

Holds Datadog RUM until the visitor accepts OneTrust's analytics category, then reports the accepted categories as session context.

Maintainerconsentv0.1.0schema 1.0.0

Install

import { datadogRum } from '@datadog/browser-rum'
import { oneTrustPlugin } from '@kyletaylored/datadog-rum-plugin-onetrust'

datadogRum.init({
  applicationId, clientToken, site, service, env, version,
  plugins: [oneTrustPlugin()],
})

The CDN URL is pinned to an exact version and needs the integrity hash from that release; there is no auto-updating latest URL. Platform path: Google Tag Manager Custom HTML tag.

Events this plugin sends

None. A consent adapter emits no custom actions of its own: it holds RUM until the visitor accepts, then reports the accepted categories as session context.

Session context it sets

PropertyExample value
consent.categories["C0001","C0002"]

What it touches

Platform globals readwindow.OnetrustActiveGroups, window.Optanon, window.OptanonWrapper
Platform events subscribedOneTrustGroupsUpdated, Optanon.OnConsentChanged, OptanonWrapper, pagehide
Storage keys writtennone
RUM APIs calledsetTrackingConsent, setGlobalContextProperty
Consent sourceOneTrust OnetrustActiveGroups

Declared by the plugin and checked against its fixture run: the conformance suite fails if the adapter calls a RUM API this list does not mention. Also printed to the console in debug mode.

Options

OptionDefaultEffect
category"C0002"OneTrust category that must be active before RUM may collect. Accepts an array for sites that require several.
reportCategoriestrueSend the accepted categories as the consent.categories global context property.
timeoutMs10000How long to wait for the banner script before warning. RUM stays held either way.
debugfalseLog consent transitions to the console.

Compatibility and maintainer

RUM SDK@datadog/browser-rum@>=7.0.0 <8.0.0
Schema1.0.0 · reference
Platforms
OneTrust Cookie Consent
Any site running the OneTrust banner script (otSDKStub.js).
MaintainerKyle Taylor (@kyletaylored)
Sourcepackages/plugin-onetrust

Verify the install

  1. Pass debug: true and reload. Every mapped event prints to the console, along with the plugin's declared footprint.
    plugins: [oneTrustPlugin({ debug: true })]
  2. Query the RUM Explorer for the first action. It should appear within a minute of the first matching interaction on the site.
    @type:session @context.consent.categories:*
  3. Reconcile against the platform's own report before trusting the numbers. These are browser-measured and will undercount; the accuracy bar is within 5% of the platform admin over 7 days.