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 | |
apiKey | Required | |
callback | Required for JSONP | |
p | Required | |
s | Required | |
targetType | Required | |
u | Required | |
vg | Optional |
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' ] } }