Pushes a custom dimension for a particular user to the VWO server. It is used for post-segmenting the data in the campaign reports.

Description

The API method:

  • Validates the parameters passed
  • Sends an asynchronous impression to the VWO server for associating custom dimension(s) for the user that became part of the FullStack campaign.

The API method accepts a custom dimension key - customDimensionKey, custom dimension value - customDimensionValue, and user-id - userId.

customDimensionKey is the unique key associated with a particular custom dimension created in the VWO application.
customDimensionValue is the value you want to associate with the custom dimension.
userId is the unique ID associated with the user for identification.

Parameter Definitions

ParameterTypeDescription
customDimensionKey
Required
StringThe custom dimension key to uniquely identify a custom dimension.
customDimensionValue
Required
StringThe custom dimension value for a custom dimension.
userId
Required
StringUser ID, which uniquely identifies each user.

Important: This User ID must match the User ID provided to activate or getVariation API.

Returns

A boolean value based on whether the call was made to the VWO server.

ValueTypeDescription
trueBooleanIf call is successfully being made to the VWO server for post-segmentation
falseBooleanIf validation fails or call is not made

Usage

vwoClientInstance.push(customDimensionKey, customDimensionValue, userId);

Tracking Multiple Custom Dimensions simultaneously

There would be instances when you would like to push more than one custom dimension associated with a particular user. To solve this, you can refer to the below docs and make sure you're using the latest SDK.

ParameterTypeDescription
customDimensionMap
Required
ObjectAn object to provide different custom dimensions associated with the user in form of key-value pairs.
userId
Required
ObjectUser ID, which uniquely identifies each user.

Important: This User ID must match the User ID provided to activate or isFeatureEnabled API

Usage

const customDimensionMap = {
  browser: 'chrome',
  price: '20'
};

vwoClientInstance.push(customDimensionMap, userId);

๐Ÿ“˜

Note

This will make multiple asynchronous tracking calls to the VWO server corresponding to each key-value pair.

Promises and async

If your application uses promises for asynchronous operations, you can configure the SDK to manage asynchronous operations. VWO SDK is capable of returning a value as well as promise depending on the use case.
When returning a value, API response time is faster (< 50ms) as it does not wait for the asynchronous tracking call to get completed. in the case of returning a promise, API will wait for both the decision as well as the asynchronous tracking call to get completed, and thereby, the response time of the API will include the round-trip time of the network call.

Since the async/await syntax is based on Promises, all APIs will also work with it.

Configuring the SDK

You can pass returnPromiseFor option at the time of instantiating the SDK i.e. while using launch API.
The returnPromiseFor option is an object and you can use it either to enable promise-based response from all the APIs or select the required API(s).

const vwoInstance = vwoSdk.launch({
  settingsFile,
  returnPromiseFor: {
    all: true
  }
});

// Or just for push API

const vwoInstance = vwoSdk.launch({
  settingsFile,
  returnPromiseFor: {
    push: true
  }
});

Example

// Using the .then() method to add a handler for a Promise
vwoClientInstance.push(tagKey, tagValue, userId).then(response => {
  // your application code
});

// Using "await" instead, within an async function
const response = await vwoClientInstance.push(tagKey, tagValue, userId);