--- title: "Functions (Help Center / APIs & MCP / JS API)" ai_context: "Use this article for questions about direct RUMvision JavaScript functions and utilities exposed through `rumv()`, including `pagehit`, `send`, `dnt`, `viewport`, `now`, `date` and `uuid`. It covers manually creating navigations or pagehits, sending currently collected RUM data, stopping tracking with do-not-track behaviour, persisting DNT state with sessionStorage when storage consent allows it, and using RUMvision timing, viewport and UUID helpers to align custom data or dimensions with values RUMvision uses internally. Relevant for SPA tracking, soft navigations, Safari or Firefox fallbacks, manual route changes, user-interaction based navigations, forced beacon sending, opt-out handling, browser session persistence, performance timing references, viewport dimensions and plugin-provided functions such as error or conversion APIs." canonical: "https://www.rumvision.com/help-center/apis/js/functions/" --- Breadcrumbs: [Home](https://www.rumvision.com/?format=md) > [Help Center](https://www.rumvision.com/help-center/?format=md) > [APIs](https://www.rumvision.com/help-center/apis/?format=md) > [JS API](https://www.rumvision.com/help-center/apis/js/?format=md) > Functions # Functions RUMvision exposes direct JavaScript functions through the same `rumv()` API. > **Requirement:** Make sure the RUMvision JavaScript API is enabled. See [JavaScript API requirements](https://www.rumvision.com/help-center/apis/js/introduction/?format=md#requirement). ## Introduction Unlike `get`, `set` and `config`, functions perform an action or return a utility value directly. Examples include creating a pagehit, forcing data to be sent, generating a UUID or reading the current viewport. ### Available functions Function Purpose `rumv('pagehit', ...)` Create a new RUMvision navigation/pagehit `rumv('send')` Immediately send data for the current navigation `rumv('dnt')` Stop tracking the current navigation `rumv('viewport')` Return the current viewport dimensions `rumv('now')` Return the current page-relative performance time `rumv('date')` Return the current Unix timestamp `rumv('uuid')` Generate a UUID Additional functions can be exposed by enabled plugins. ## Tracking RUMvision already handles most regular hard navigations and supported soft navigations automatically. For soft navigations, this is largely covered through our integration with the Soft Navigation API in the web-vitals library. See our [SPA & soft navigation monitoring introduction](https://www.rumvision.com/help-center/monitoring/spa-soft-navs/introduction/?format=md) for more information. The tracking functions below are therefore mainly useful when you deliberately want to create or control a navigation outside the normal hard-navigation or soft-navigation flow, or within browsers that do not support the Soft Navigations API. For example, you may want to start a new RUMvision navigation after a specific user interaction that represents a meaningful new view or state in your application. ### pagehit Use `pagehit` to manually create a new RUMvision navigation. A navigation type is required: ``` rumv('pagehit', 'soft-navigation'); ``` You can optionally provide more navigation context: ``` rumv('pagehit', navType, url, navId, startTime); ``` Argument Purpose `navType` Navigation type. Required. `url` Navigation URL. The current URL is used when omitted. `navId` Existing navigation/request identifier. A UUID is generated when omitted. `startTime` Optional `performance.now()` based start time. RUMvision already handles normal page loads and supported browser navigation scenarios automatically. Manual pagehits are mainly useful when your application knows about a navigation that RUMvision cannot identify automatically. For SPA implementations, prefer RUMvision's built-in soft-navigation support where it covers your framework. ### send Use `send` to immediately send the currently available data: ``` rumv('send'); ``` RUMvision normally manages beacon timing automatically. A manual send is useful when your application has a specific lifecycle moment at which currently collected information should be submitted immediately. The call returns RUMvision's transport result or promise. A specific navigation can also be supplied when available: ``` rumv('send', navId); ``` Most integrations only need: ``` rumv('send'); ``` ### dnt Use `dnt` to stop tracking the current navigation: ``` rumv('dnt'); ``` RUMvision cancels pending send work for that navigation where possible, marks the current RUM session state as opted out and prevents that navigation from being tracked further. This is different from: ``` rumv('config', 'consent_storage', 0); ``` `consent_storage` controls whether RUMvision may use browser storage, while `dnt` stops RUM tracking for the navigation itself. To make `dnt` persist across pagehits, RUMvision still needs access to `sessionStorage`. This allows the opt-out state to be remembered for the remainder of the browser session instead of only affecting the current pagehit. For that reason, disabling storage completely is not the same as using `dnt`. If `consent_storage` is disabled, RUMvision cannot persist this state itself. In that case, your own implementation should call `rumv('dnt')` again on every new pagehit for as long as the visitor should remain opted out. ## Utilities These utility functions are mainly intended to help you align custom data and dimensions with the same values and timing references RUMvision uses internally. This can be useful when you need to enrich custom data in a way that stays consistent with RUMvision's own measurements. ### viewport Get RUMvision's current viewport dimensions: ``` const viewport = rumv('viewport'); ``` A typical result: ``` {w: 1440, h: 900} ``` RUMvision prefers `visualViewport` where available and otherwise falls back to document or window dimensions. ### now Get the current page-relative timing value: ``` const time = rumv('now'); ``` This returns a rounded value based on: ``` performance.now() ``` It is useful for timings relative to the current document lifecycle. ### date Get the current Unix timestamp in milliseconds: ``` const timestamp = rumv('date'); ``` This is equivalent to: ``` Date.now() ``` ### uuid Generate a UUID: ``` const id = rumv('uuid'); ``` RUMvision uses the browser's native: ``` crypto.randomUUID() ``` This can be useful when an integration needs an identifier without loading another utility. ## Plugins Enabled RUMvision modules can register additional functions. Their availability depends on the generated script for the domain. ### error When error tracking is enabled, handled errors can be reported manually: ``` try { initializePayment(); } catch (error) { rumv('error', error); } ``` Additional error context can also be supplied: ``` rumv('error', { error, message, filename, lineno, colno }); ``` Manual reporting does not swallow or rethrow the error. Your application remains responsible for its own error handling. ### event When the conversions plugin is enabled, it can expose: ``` rumv('event', ...); ``` The accepted arguments depend on the conversion configuration generated for the domain. ### define The conversions plugin can also expose: ``` rumv('define', ...); ``` Its accepted configuration depends on the conversion definitions for the domain. Plugin-specific functions should be documented together with the relevant feature because they are not universally available. ## Examples Create a manual soft navigation: ``` rumv('pagehit', 'soft-navigation'); ``` Immediately send the current data: ``` rumv('send'); ``` Stop tracking the current navigation: ``` rumv('dnt'); ``` Read the viewport: ``` const viewport = rumv('viewport'); ``` Generate a UUID: ``` const id = rumv('uuid'); ```