---
title: setCustomVariables
slug: js-api/setcustomvariables
description: Overview of the Monetate JavaScript API setCustomVariables method and how to use it
image:  https://archbee-image-uploads.s3.amazonaws.com/ceIfEvQHzQk1IVxoRWUh7/K9eTL4jKm7UQINb6zNziJ-20250912-181225.png
docTags: 
createdAt: 2024-04-30T18:28:39.973Z
---

:::CodeblockTabs
SetCustomVariables Method

```javascript
// setCustomVariables Method
monetateQ.push(['setCustomVariables', [
  {
    name: 'test1',
    value: '1'
  },
  {
    name: 'test2',
    value: 'test2'
  }
]]);
```
:::

The `setCustomVariables` method provides a way to indicate that a custom variable is present on your site. This method takes an array of JavaScript objects, each with the key's name and value, both of which can be a string or a number.

:::hint{type="info"}
You must implement this method to use custom variable options available for [WHO Landing targets](https://docs.monetate.com/docs/custom-context-variables-overview#using-custom-variables-in-who-targets), [recommendations filters](https://docs.monetate.com/docs/filters-in-recommendations#value-of-custom-variable-filter), and [action conditions](https://docs.monetate.com/docs/action-conditions#using-a-custom-variable).
:::

For example, you can track membership levels for individual customers. You can report a custom variable called membership and return the membership level for a site visitor.

For example, your site has a rewards program that allows members to earn badges. You know that a customer currently logged into the site has earned Penguin status and that they're four stars away from Pelican status. You can use `setCustomVariables` to account for this data.

## Monetate Inspector View

The [Monetate Inspector tool](https://docs.monetate.com/docs/install-the-monetate-inspector-browser-plug-in) reports custom variables identified by `setCustomVariables` on the **Track** tab. This screenshot shows that it has found two custom variables and their associated values: `rewardStatus` and `starsNeededForPromotion`.

![The Components tab of Monetate Inspector, with rewardStatus and starsNeededForPromotion in the Custom Variables row](https://dyzz9obi78pm5.cloudfront.net/app/image/id/64f785afa6bb6d78c8187d95/n/monetate-inspector-components-tab-event-viewpage-custom-variables-rewardstatus-starsneededforpromotion.png)

This code example contains the method in use that results in the Monetate Inspector results shown in the previous screenshot.

:::CodeblockTabs
setCustomVariables Example

```javascript
// setCustomVariables Example
window.monetateQ = window.monetateQ || [];
monetateQ.push(['setCustomVariables', [
  {
    name: 'rewardStatus',
    value: 'penguin'
  },
  {
    name: 'starsNeededForPromotion',
    value: '4'
  }
]]);
window.monetateQ.push([
  "trackData"
]);
```
:::

