Skip to main content
RichRelevance

user/preference

Important: Only call parameters that you need. Personalization Cloud operates off a set of APIs that support many applications and clients concurrently. Personalization Cloud may update and enhance these APIs at any time. 

http://recs.richrelevance.com/rrserver/api/user/preference
Note: The URL requires the API key and parameter(s) to function properly. See below for more information on example URL requests.
 
Description: Records the customer’s preferences in the Personalization Cloud. Customers can like or dislike individual products, brands, categories, and stores. Customers can also single out products that they don’t  want to see in recommendations.
 

Parameters

Note: All parameters are case sensitive.

Name Required or Optional Description
actionType Required

Brands, categories, products, and stores indicated by the shopper in the p (preference) parameter. Must be one of these values: dislike, like, neutral, notForRecs. Setting actionType to a value of neutral undoes a previous like or dislike.

The notForRecs value flags products that should not be recommended without disliking them. For example, if a customer already owns a particular product, they might like it, but not want to see it again. Products flagged with notForRecs are also removed as seeds from all Personalized Strategies.

Example: actionType=like

apiKey Required

A unique key that identifies the site. Each RichRelevance client has a unique API key to separate data and traffic from other clients. This is provided by RichRelevance.

Example: apiKey=4faeaf752ee40a0f

callback Required for JSONP

Name of the JavaScript function that JSON data will be passed to. It must be specified for JSONP. The value of this parameter is used as the name of the js function in the response.

Example: callback=products_returned

p Required

Preference. A list of brand IDs, category IDs, product IDs, or store IDs. This depending on the value of targetType. Use the pipe "|" character to separate values.

Example: p=Microsoft|Logitech|Apple (this example is if targetType=brand)

s Required

Session ID. Identifies one visit, or the use of a site/application by a shopper. Used to determine “scope” when building behavioral models.

Example: s=93484

targetType Required

The value passed as a preference. It must be one of these values: brand, category, product, or store.

Example: targetType=brand

u Required

User ID. A unique string to identify each shopper (user). All shopper behavior is stored using this key. It is case-sensitive, and should be the same user ID sent to RichRelevance in other applications.

Example: u=0982347

vg Optional

View GUID. A unique string to identify a set of recommendations. It's returned as part of the RichRelevance response.

Example: vg=1a477338-4fae-4185-e637-3252c78feade

Example Request

GET

http://recs.richrelevance.com/rrserver/api/user/preference?apiKey=showcaseparent&s=10&u=1&vg=1a477338-4fae-4185-e637-3252c78feade&p=21653692&targetType=product&actionType=like

JavaScript Example Request

function logPreference(action, target, externalId) {
  var prefUrl="http://recs.richrelevance.com/rrserver/api/user/preference?apiKey="+ R3_COMMON.apiKey + "&s="+ rrSessionId + "&u=" + R3_COMMON.userId +"&vg=" + RR.pq('vg') + "&p=" + externalId + "&targetType="+ target +"&actionType=" + action;
  jQuery.ajax(prefUrl, {
    dataType: "jsonp",
    success: function(data, status) {
      console.log(data);
    }
  });
 }
function likeBrand() {
  logPreference("like", "brand", R3_COMMON.brand);
  }
function unlikeBrand() {
  logPreference("neutral", "brand", R3_COMMON.brand);
  }
function likeItem() {
  logPreference("like", "product", R3_ITEM.id);
  }
function unlikeItem() {
  logPreference("neutral", "product", R3_ITEM.id);
  }
function retrievePreferences(target) {
  var prefUrl="http://recs.richrelevance.com/rrserver/api/user/preference/" + R3_COMMON.userId + "?apiKey="+ R3_COMMON.apiKey + "&u=" + R3_COMMON.userId +"&fields=pref_" + target;
  jQuery.ajax(prefUrl, {
    dataType: "jsonp",
    success: function(data, status) {
      console.log(data);
    }
  });
}

Example Result

200 OK

{
   'userId':'USER185',
   'pref_product':{
      'like':[
         '1234',
         '5678'
      ],
      'dislike':[
         'abcd'
      ]
   },
   'pref_brand':{
      'like':[
         'Sony',
         'Nabisco'
      ]
   },
   'pref_category':{
      'like':[
         '8989',
         '8080'
      ]
   },
   'pref_store':{
      'like':[
         'ca_128'
      ]
   }
}
  • Was this article helpful?