SDK Objects

The SDK consists of the following classes.

Personalization Class

Personalization is the main class. You can use an instance of this to invoke the different methods of SDK.

Import this class using the following code:

import personalization from '@personalization-js-sdk/react-native';

Create an instance of this class using the following code:

const personalizationInstance = personalization (  
  account,
  user
)

account and user are classes, and must be initialized to use as arguments for creating an instance of personalization. Refer to the objects below for information on how to initialize them.

Account Object

This object contains information about the account.

Export this class using the following code:

export const account = {
  domain: '', // Domain name
  name: '', // Account name
  instance: '', // Instance for the domain
  shortname: '', // Short name for the account
};

You must provide data for these variables.

Example code:

const account = {
  domain: "monetate.mybigcommerce.com",
  name: "a-3e41bf76",
  instance: "p",
  shortname: "monetatebc",
};

User Object

This object contains information about the user.

Create an instance of this class using the following code:

export const user = {
  deviceId: '', // Device ID
  monetateId: '', // Monetate ID
  customerId: '', // Customer ID
};

When creating this object, you must set either the device ID or the Monetate ID. The recommended ID to use is the device ID.

  • monetateId: This is used for customer identification. You can generate this ID using the generateMonetateID method of the Personalization class.
  • deviceId: This identifies the mobile device ID and is provided by the customer. This is used for customer identification. The recommended ID to use.
  • customerId: This ID is optional. If you define it here, you must also pass it in calls with the other ID you use. You can later change the customer ID with the setCustomerId method.

You can store the device ID or Monetate ID locally to re-identify to the same customer again later.