SDK Objects
the monetate 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 code to import personalization class import personalization from '@personalization js sdk/web'; account and user are objects, and must be initialized to use as arguments for creating an instance of personalization refer to the object descriptions in this documentation for information on how to initialize them create an instance of this class using the following code code to create a personalization class instance const personalizationinstance = personalization ( account, user ) import this class using the following code code to import personalization class import personalization from '@personalization js sdk/react native'; account and user are objects, and must be initialized to use as arguments for creating an instance of personalization refer to the object descriptions in this documentation for information on how to initialize them create an instance of this class using the following code code to create a personalization class instance const personalizationinstance = personalization ( account, user ) code to import personalization class import foundation import monetate ios sdk account and user are classes, and must be initialized to use as arguments for creating an instance of personalization refer to the object descriptions in this documentation for information on how to initialize them create an instance of this class using the following code code to create a personalization class instance final var personalization = personalization(account account(instance "p", domain "localhost org", name "a 701b337c", shortname "localhost"), user user(monetateid "2 1454546575 1711006580023", deviceid "62bd2e2d 213d 463f 83bb 12c0b2530a14", customerid "12345")) create an instance of this class using the following code code to create a personalization class instance 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 object descriptions in this documentation for information on how to initialize them if any of the parameters of the account class are missing, then this class constructor throws the accountdetailsexception you must handle the exception using this class here's an example example code to handle accountdetailsexception try { personalization personalization = new personalization(user, account); } catch (accountdetailsexception e) { e printstacktrace(); } account object this object contains information about the account export this class using the following code code to export account object 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 this object export this object using the following code code to export account object 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 this object export this class using the following code code to export account object let account = account( instance , // instance for the domain domain , // domain name name , // account name shortname // short name for the account ) you must provide data for this class create an instance of this class using the following code code to export account object 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 this class code example example code to export account object const account = { domain "monetate mybigcommerce com", name "a 3e41bf76", instance "p", shortname "monetatebc", }; example code to export account object const account = { domain "monetate mybigcommerce com", name "a 3e41bf76", instance "p", shortname "monetatebc", }; example code to export account object let account = account( instance "p", // instance for the domain domain "localhost org", // domain name name "a 701b448c", // account name shortname "localhost" // short name for the account ) example code to export account object 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 code to create user object instance export const user = { deviceid '', // device id monetateid '', // monetate id customerid '', // customer id }; when creating this object, you must provide 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 sdk methods method of the personalization class deviceid — this identifies the mobile device id and is provided by the customer 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 sdk methods method you can store the device id or monetate id locally to identify the same customer later create an instance of this class using the following code code to create user object instance export const user = { deviceid '', // device id monetateid '', // monetate id customerid '', // customer id }; when creating this object, you must provide either the device id or the monetate id the recommended id to use is the device id monetateid — used for customer identification you can generate this id using the sdk methods method of the personalization class deviceid — the mobile device id and is provided by the customer 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 sdk methods method you can store the device id or monetate id locally to identify the same customer later create an instance of this class using the following code code to create user object instance let user = user( monetateid , // monetate id deviceid , // device id customerid // 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 — an id generated from the monetate server you can generate this id using the sdk methods method of the personalization class deviceid — the id of the customer's device the recommended id to use customerid — the id of the customer 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 sdk methods method when you create a personalization object for the first time, there is no monetate id to associate with the user object you must first initialize a user object with a device id after you do that, you can generate a monetate id for the user object by calling the generatemonetateid method the following example code demonstrates how to do this example code to call the generatemonetateid method final var objpersonalization = personalization(account account(instance "p", domain "localhost org", name "a 701b337c", shortname "localhost"), user user(deviceid "62bd2e2d 213d 463f 83bb 12c0b2530a14", customerid "12345")) let monetateid = objpersonalization generatemonetateid() create an instance of this class using the following code code to create user object instance 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 class, 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 — used for customer identification you can generate this id using the sdk methods method of the personalization class deviceid — the mobile device id and is provided by the customer 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 sdk methods method you can store the device id or monetate id locally to identify the same customer later