---
updatedAt: 2025-06-23T22:28:03.000Z
agentTools:
  projectIndex: https://support.speedcurve.com/llms.txt
---

# Using the JS RUM API

How to use the JS RUM API to add custom data

**\[Supported in SpeedCurve RUM only]**

The [JS RUM API](https://support.speedcurve.com/docs/rum-js-api#luxadddataname-value) (lux.js) contains multiple properties, functions and attributes that can be used to customize SpeedCurve RUM to your application. You can define [Custom Data](https://support.speedcurve.com/docs/custom-data) using the `LUX.addData()` function of the API.

# Tracking conversions with the JS RUM API

**Step 1**

To get started, after clicking on 'Add Conversion', select the JS RUM API option and click 'Next'.

<Image align="center" width="640px" src="https://files.readme.io/d6e0a3a-add_conversion_js_rum_1.2.gif" />

**Step 2**

Enter the name you want to use for the conversion. This is the value that will be shown in your charts and dashboards. Enter the JS RUM API variable name you will include in your code.

<Image align="center" width="640px" src="https://files.readme.io/8574058-conversion_entry_1.2.gif" />

**Step 3**

Once complete, you will see your conversion listed on the custom data page.

<Image align="center" width="815px" src="https://files.readme.io/3cccb8d-conversion_variable_set.gif" />

To track a conversion with this method, you must use the `LUX.addData` API at the point where a user has converted.

## On a static page

You can track conversions on a static page like the order confirmation page by calling `LUX.addData()` anywhere on the page after the RUM snippet.

```javascript
LUX.addData('order_confirmed', 1)
```

This data will be sent to SpeedCurve as part of the main RUM beacon.

## As part of a single page transaction

You can also track conversions on pages where the conversion is triggered dynamically with JavaScript. For example after sending a `POST` request to finalise a transaction:

```javascript
fetch('/transactions/confirm', { method: 'POST' }).then(response => {
        if (response.status === 200) {
            LUX.addData('order_confirmed', 1)
        }
})
```

If `LUX.addData()` is called after the main RUM beacon has been sent, then this data will be sent to SpeedCurve in a separate beacon. Otherwise it will be sent in the main beacon.

# Adding dimensions and metadata using the JS RUM API

> 📘 Note
>
> You can follow the same steps below to add custom metadata

**Step 1**

To get started, after clicking on 'Add Dimension', select the JS RUM API option and click 'Next'.

<Image align="center" width="640px" src="https://files.readme.io/4f281c3-add_dimension_options.gif" />

**Step 2**

Enter the name you want to use for the dimension. This is the value that will be shown in your charts and dashboards. Enter the [JS RUM API](https://support.speedcurve.com/docs/rum-js-api) variable name you will include in your code.

<Image align="center" width="640px" src="https://files.readme.io/96669e5-dimension_abtest_1.2.gif" />

**Step 3**

Once complete, you will see your dimension listed on the custom data page.

<Image align="center" width="815px" src="https://files.readme.io/599eabf-dimension_js_final.gif" />

To create a dimension with this method, use the `LUX.addData` API when you want the dimension applied to the user's session.

## Adding dimension data to a session

Usage:

```javascript
LUX.addData(name, value);
```

Using the example above for an AB TEST

```javascript
LUX.addData('ab_test', 'variant1234');
```

# Adding metrics using the JS RUM API

> 📘 Note
>
> The following steps can be used to define any metric type (Timing, Size or Numeric)

**Step 1**

To get started, after clicking on 'Add Metric', select the metric type and click 'Next'.

<Image align="center" width="640px" src="https://files.readme.io/549ae46-add_metric_types_1.2.gif" />

**Step 2**

Select JS RUM API and click next.

<Image align="center" width="640px" src="https://files.readme.io/0990bc0-add_metric_js_1.2.gif" />

**Step 3**

Enter the name you want to use for the metric. This is the value that will be shown in your charts and dashboards. Enter the JS RUM API variable name you will include in your code and the time unit for data collection in milliseconds or seconds. (Timing metrics will be displayed as seconds in your dashboards)

<Image align="center" width="640px" src="https://files.readme.io/8fb458d-add_jsrum_querytime_1.2.gif" />

**Step 4**

Once complete, you will see your dimension listed on the custom data page.

<Image align="center" width="815px" src="https://files.readme.io/5cdc982-add_metric_final.gif" />

## Adding metric data to a session

Usage:

```javascript
LUX.addData(name, value);
```

Metric type examples:

```javascript
LUX.addData('database_query_time', '55.4'); //Custom timing metric
LUX.addData('memory', '5447'); //Custom size metric
LUX.addData('cart_item_count', '3'); //Custom numeric metric
```