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.

Create an instance of this class using the following code:

Personalization personalization = new Personalization(user,account);

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.

If any of the parameters of the Account object are missing, this class constructor throws the AccountDetailsException. You must handle the exception using this class. Example code:

try    
  {
    Personalization  personalization = new Personalization(user, account);
  } catch (AccountDetailsException e) {
    e.printStackTrace();
  }

Account Object

This object contains information about the account.

Create an instance of this class using the following code:

Account account = new Account();     
account.setDomain(""); // Domain name
account.setName(""); // Account name
account.setInstance(""); // Instance for the domain
account.setShortname(""); // Short name for the account

You must provide data for these variables.

Example code:

Account account = new Account();     
account.setDomain("monetate.mybigcommerce.com");
account.setName("a-3e41bf76");
account.setInstance("p");
account.setShortname("monetatebc");

User Object

This object contains information about the user.

Create an instance of this class using the following code:

User user = new User();
// Set only one of these IDs
user.setDeviceId("1109349827122"); // Device ID
user.setMonetateId("2.1189737281.1718190856247"); // Monetate ID
// Set the customer ID only if you have one
user.setCustomerId("customer@xyz1234567"); // Customer ID

When creating this object, you must set either the device ID or the Monetate ID with the above method calls. 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.