User Profile (JS SDK)

Update User Profile

Method Objective

The method updates the user's profile or creates a new profile bound to the user's current device if it was not created earlier.

If you don't have user data, never send bogus data. It'll cause problems in profile handling in the future. For example, don't send a non-existent email, like anonymous@example.com, or an automatically generated email address that doesn't have anything to do with the user's actual email.

Syntax and parameters

personaclick("profile", "set", params, success, error);

NameTypeRequirementDescription
paramsObjectrequiredObject with request parameters.
successFunctionoptionallyA callback function, to which the API response will be passed. Response type: object.
errorFunctionoptionallyA callback function that will be called when an error occurs (any HTTP status code other than 200).

Main request parameters

User data must be sent each time it becomes available:

  • after the user's registration is complete
  • after the user has logged in to the account
  • email or phone number (if available) of the authorized user on each page of the site
  • on the checkout page, if the user is registering (or authorizing) at the time of order placement

Name

Type

Description

email  

string

User Email.

first_namestringUser First Name.
genderstringUser Gender (m – male, f – female).
idnumber/stringStore side user ID.
last_namestringUser Surname.
phonestringUser Phone.

Additional request parameters

Name

Type

Description

agenumber

User age (in years).

autoObject arrayList of vehicles. See description below.
birthdaystring

User birthday in the format YYYY-MM-DD.

bought_somethingbooleanThe user has or hasn't ever bought something in the store.
fb_idstringFacebook User ID.
kidsObject arrayUser's children. See description below.
locationstring

The user's current location from the list of locations in the product feed.

loyalty_bonusesnumberThe current number of store bonuses at the user.
loyalty_bonuses_to_next_levelnumberThe number of store bonuses necessary for the user to reach the next loyalty level.
loyalty_card_locationstringThe location (from the list of locations in the product feed) where the user last used the loyalty card.
loyalty_idstringThe Loyalty Program user ID (loyalty card).
loyalty_statusstringThe user's current status in the loyalty program.
telegram_idstringTelegram User ID.
vk_idstringVKontakte User ID.

The "auto" object properties

Name

Type

Description

brandstring

Vehicle Brand.

modelstringVehicle Model.
vdsstring

Vehicle's VDS/VIN.

The "kids" object properties

Name

Type

Description

genderstringChild's age (m – male, f – female).
birthdaystringChild's birthday in the format YYYY-MM-DD.

Custom Properties

NameTypeDescription
A custom property can have any name except the reserved onesstring

The custom property must be created before it can be used. Located there: Account > Settings > Profile Property

If property creation isn't available in the account, contact PersonaClick support.

integer
float
array of string
json
date (YYYY-MM-DD hh:mm:ss)

Example of use

personaclick("profile", "set", {
    id: 100500,
    email: "john.doe@examplemail.com", 
    phone: "4400114527199",
    first_name: "John", 
    last_name: "Doe",
    birthday: "1990-03-11", 
    age: 31,
    gender: "m", 
    location: "NY",
    bought_something: true,
    loyalty_id: "000001234567",
    loyalty_card_location: "NY",
    loyalty_status: "5% discount", 
    loyalty_bonuses: 1123,
    loyalty_bonuses_to_next_level: 1877,
    fb_id: "000000000354677",
    vk_id: "vk031845",
    telegram_id: "0125762968357835",
    kids: [
        {gender: "m", birthday: "2001-04-12"},
        {gender: "f", birthday: "2015-07-28"}
    ],
    auto: [
        {brand: "Nissan", model: "Qashqai", vds: "TM7N243E4G0BJG978"}
    ],
    custom_string_property: "the string value of the custom property",
    custom_integer_property: 100500,
    custom_float_property: 7.62,
    custom_array_of_string_property: ["value1", "value2", "value3"],
    custom_json_property: {key1: value1, key2: value2, key3: value3},
    custom_date_property: "2021-12-31 23:55:00"
});



Read User Profile

Method Objective

The method returns accumulated (depersonalized) profile data of the current user.

Most of the data is computational based on the user's interaction with the products.

Syntax and parameters

personaclick("profile", "get", callback, force);

NameTypeRequirementDescription
callbackFunctionrequiredThe callback function that takes the API response. The API response type is an object.
forcebooleanoptionallyAllows disabling data caching. By default, caching is enabled.

API response

Name

Type

Description

genderstring

The gender of the current user.

If not forced by the "Update User Profile" method, it has the same value as the "computed_gender" property (see below).

computed_genderstringThe calculated value of gender is based on the user's interaction with the products.
childrenObject array

Data about the children of the current user. Each element of the array can contain the following properties:

  • gender (string) - the child's gender
  • birthday (string, YYYY-MM-DD format) - the child's birthday
  • age (number) - the сhild's age
cosmetic_hairobject

The hair properties of the current user:

  • type (string) - Hair Type. See available values for hair types in the Cosmetics & Perfumes section.
  • condition (string) - Hair Condition. See available values for hair conditions in the Cosmetics & Perfumes section.
cosmetic_skinobject

The skin properties of the current user:

  • body (object) - Body Skin Properties
  • hand (object) - Hands Skin Properties 
  • leg (object) - Legs Skin Properties 

Each of the properties above has the following properties and values:

  • type (string) - Skin Type. See available values for skin types in the Cosmetics & Perfumes section.
  • condition (string) - Skin Condition. See available values for skin conditions in the Cosmetics & Perfumes section.
cosmetic_perfumeobject

Perfume preferences of the current user. The following properties and values are available:

allergybooleanWhether the current user is allergic.
fashion_sizesobject

Lists clothing types with preferred sizes for each. See available type values in the Apparel & Accessories section. 

The value of each property is an array with the user's preferred clothing sizes.

compatibilityobject

The preferred brand and model of the vehicle. The following properties are available:

  • brand (string)
  • model (string)
vdsstringThe fourth to ninth position in the VIN is the Vehicle Descriptor Section or VDS.
petsobject

The user's pet. The following properties are available:

  • type (string) - Type of Pet. See available type values in the Pet Products section.
  • breed (string) - Breed of Pet. 
  • size (string) - Size of Pet. See available size values in the Pet Products section.
  • age (string) - Age of Pet. See available age values in the Pet Products section.
jewelryobject

The jewelry preferences of the current user. The following properties are available:

  • metal (String array) - Preferred Metal. See available metal values in the Jewelry section.
  • color (String array) - Preferred Color. See available color values in the Jewelry section.
  • gem (String array) - Preferred Gem. See available gem values in the Jewelry section.
  • gender (String array) - Gender. Available values: "m" or "f".
  • ring_size (Number array) - Preferred ring sizes of the current user.
  • bracelet_size (Number array) - Preferred bracelet sizes of the current user.
  • chain_size (Number array) - Preferred chain sizes of the current user.
realtyobject

Real estate of the current user. The following properties are available:

  • type (string) - Type of Real Estate. See available type values in the Real Estate section.
  • space (number) - The area of the real estate object. 
income_levelstringThe income level of the current user. Available values: cheap, medium, premium.
has_emailbooleanDoes the user's profile contain an email?
custom_propertiesObjectThe object contains the values of the custom properties that were marked as available for the public part (frontend). The custom properties are located there: Account > Settings > Profile property

Example of use

personaclick("profile", "get", function(profile) {
	console.log(profile.gender);
});



Get Last Order Products

Method Objective

The method allows getting detailed information about the products of the last order of the current user.

Syntax and parameters

personaclick("orders", "last_for_user", callback, error);
NameTypeRequirementDescription
callbackFunctionrequiredThe callback function that takes the API response. The API response type is an array.
errorFunctionoptionallyA callback function that will be called when an error occurs (any HTTP status code other than 200).

API response

Each object in the array contains the following properties.

Name

Type

Description

barcodestringProduct barcode, if it was imported in the product catalog
brandstringProduct vendor
categoriesObject arrayObject array with details of the product category hierarchy, where each object has properties:
"id" – category ID (type: string)
"name" – category name (type: string)
"parent" – parent category ID (type: string)
"url" – category page url (type: string)
category_idsString arrayArray of IDs of the product category hierarchy
currencystringProduct currency (type: string, matches the currency of the PersonaClick account, or the user value set in the settings of the PersonaClick account)
descriptionstringProduct description
discountnumberThe percentage difference between the old price and current price
discount_formattedstringThe percentage difference between the old price and current price that is formatted as a string with the "%" symbol
fashion_colorsObject arrayObject array with details of the product category hierarchy, where each object has properties:
"color" – product color (type: string)
"picture" – color-matched product image (type: string)
fashion_original_sizesarrayOriginal product sizes
fashion_sizesarrayNormalised product sizes (see XML)
idstringProduct ID
image_urlstringURL of the original product image
image_url_handlestringRelative URL of the original product image
image_url_resizedObjectObject with the URLs of the resize product image. Available object keys matching the size of the image in pixels: 120, 140, 160, 180, 200, 220, 310, 520
is_newbooleanNew arrival product (type: boolean). See the parameter in the product catalog import (XML, HTTP API)
leftoversstringRough number of the products left in stock. Available values are: 
"one" - one product
"few" - 2-10 products
"lot" - over 10 products
modelstringModel and product name
namestringProduct name
oldpricenumberInteger old price of the product
oldprice_formattedstringFormatted integer old price of the product, including currency
oldprice_fullnumberOld price of the product
oldprice_full_formattedstringFormatted old price of the product, including currency
paramsObject array Object array with pairs of "key" (type: string), "values" (type: array) properties. The data matches the values of the "param" parameter of the product feed/catalog (XML, HTTP API).
pricenumberInteger current price of the product
price_formattedstringFormatted integer current price of the product, including currency
price_fullnumberCurrent price of the product
price_full_formattedstringFormatted current price of the product, including currency
ratingnumberProduct rating
stock_quantitynumberThe available quantity of products
urlstringProduct page URL 
url_handlestringRelative product page URL

Example of use

personaclick("orders", "last_for_user", function(products) {
	console.log(products);
});

Copyright 2018-2024 PersonaClick