Client JavaScript Library

This page documents the RumDash client JavaScript library API. The library tracks Core Web Vitals and other performance metrics from your website visitors in real-time.

API Reference

RumDash.init()

Initializes RumDash analytics tracking with your API key and optional metadata. This method must be called for RumDash to collect and report Core Web Vitals and performance metrics.

Parameters

  • Name
    config
    Type
    RumDashClientConfig
    Description

    Configuration object containing your API key and optional metadata

Required attributes

  • Name
    key
    Type
    string
    Description

    The API key for your website, obtained from RumDash settings. This key authenticates your website with the RumDash backend and associates analytics data with your account. You can find this in your website settings under the Installation section.

Optional attributes

  • Name
    env
    Type
    string
    Description

    Optional environment identifier. Useful for larger organizations that deploy rumdash in both prod and non-prod environments so that the data can be easily segregated.

    Default: "prod"

  • Name
    revision
    Type
    string
    Description

    Optional revision identifier for associating performance metrics with specific deployments/releases. Helpful for identifying when performance regressions/improvements were introduced. Common patterns include git commit SHAs, version number strings, or stringified deployment timestamps.

  • Name
    pageType
    Type
    string
    Description

    Optional page type identifier for categorizing different page templates. Use this to categorize pages by their type (e.g., "product", "homepage", "checkout"). This allows you to filter and compare performance across different page templates in your analytics dashboard.

    For single-page applications where the page type changes during client-side navigation, use updatePageType to update the page type dynamically.

  • Name
    enabled
    Type
    boolean
    Description

    Optional flag to disable RumDash analytics tracking. When set to false, the client will not capture or report any metrics. Useful for conditionally disabling tracking based on user/developer preference or other runtime conditions.

    Default: true

Examples

Simplest configuration with API key:

function __rdOnLoad() {
RumDash.init({
key: "your-api-key-here",
});
}

Configuration with required key and multiple optional parameters:

function __rdOnLoad() {
RumDash.init({
key: "your-api-key-here",
env: "production",
revision: "v2.1.3",
pageType: "product-category"
});
}

RumDash.updatePageType()

updatePageType is used to update page types in single-page applications (SPAs) where the page type may change via client-side navigations. Updating the page type allows for more meaningful analytics aggregation, as should be used with the init method's pageType.

Parameters

  • Name
    pageType
    Type
    string
    Description

    The page type identifier (e.g., "product-category", "product-detail-page", "search-results")

Examples

Updating page type after a client-side navigation in a SPA:

window.RumDash &&
window.RumDash.updatePageType("product-detail-page");

RumDash.disable()

Disables RumDash analytics tracking at runtime, even if it was previously enabled via init. Once called, the client will stop reporting any further metrics for the remainder of the page's lifetime. This cannot be undone without a fresh page load.

Use this when you need to turn off tracking in response to a runtime signal — for example, a user opting out of analytics, or a feature flag flipping mid-session.

Examples

Opting a user out of analytics in response to a consent-management event:

consentBanner.addEventListener("rejected", () => {
window.RumDash && window.RumDash.disable();
});