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. 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.

Perhaps 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.

Using Custom Variables in WHO Targets

You can use custom variables and their values in Web experiences to target site visitors. To accomplish this goal, when configuring the WHO part of an experience, select Landing on the Target Type panel, and then select either Custom variable visitors or Custom variable visitors with multiple values targets.

For example, you want a Web experience that targets customers with Penguin status. When configuring the WHO part of the experience, you select Custom variable visitors and then input the custom variable name and the value that you want to target, as shown in this screenshot.

Callout of the 'Variable name' and 'Variable value' fields in the

You can include or exclude from an experience site visitors associated with the custom variable value(s) you input for the custom variable you identify in the target.

Using Custom Variables with Dynamic Text in Content Builder

You can use custom variable values in dynamic text that you add to creatives that you build in Content Builder.

For example, you can add to the experience that targets all visitors with Penguin status (as collected by setCustomVariables) a banner that you create in Content Builder that states, "You are X stars away from being promoted to Pelican!" The banner is customized so that each Penguin-status visitor sees how many stars they must earn to be promoted.

To achieve the customized text, in Content Builder create a text layer, double-click it to edit it, and then click Add dynamic content on the text toolbar. Select Custom Variable from the selector on the Add dynamic content modal.

The 'Add dynamic content' selector of Content Builder, which includes the 'Custom Variable' option

Input the custom variable into the text field so that its value is inserted into the dynamic text for each visitor that views the creative.

The custom variable value placeholder 'customvar: points' placed within the body of a creative's text

The setCustomVariables method only includes in-session data. Therefore, you cannot use it across sessions for targeting. Use Target Builder if you must create a custom target.

Monetate Inspector Example

The Monetate Inspector tool 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

Code Samples

This code snippet contains a generic use of the setCustomVariables method.

// setCustomVariables Method
monetateQ.push(['setCustomVariables', [
    name: 'test1',
    value: '1'
    name: 'test2',
    value: 'test2'

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

// setCustomVariables Example
window.monetateQ = window.monetateQ || [];
monetateQ.push(['setCustomVariables', [
    name: 'rewardStatus',
    value: 'penguin'
    name: 'starsNeededForPromotion',
    value: '4'