Skip to main content
RichRelevance

service/userProfileEventStream

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.

wss://streams.richrelevance.com/upsevents/api/v2/service/UserProfileStream

Note: The URL requires the API key and parameter(s) to function properly. See below for more information on example URL requests.

Description: A web socket interface to receive all events that are streaming into the UPS (User Profile Service). When connected, you will receive one message for each event into the UPS.

Parameters

Note: All parameters are case sensitive.

Name Required or Optional Description
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

apiClientKey

Required

A unique key specific to each API implementation. It identifies the specific application or client for reporting, permissions, and merchandising. This is provided by RichRelevance.

Example: apiClientKey=b0126f995ac848159d

clientSecret Required

A unique key to authorize a client app on behalf of the partner.

Example: clientSecret=wbhz6c41

Client API Keys and Secrets

To create a client key and a client secret, contact your Algonomy team, who will make sure you have access to the Personalization Cloud dashboard. Your clientApiKey will be accessible through the dashboard, but the clientSecret is a specific value for the clientApiKey and will need to be communicated via email or phone.

Client secrets need to be kept secure. They should never be shared, and only ever passed via HTTPS.

Sample Code

The following is an example of a simple HTML+javascript code to connect to and display the event stream. Other web socket javascript  libraries can be used as well.

The ApiKey, clientApiKey, and clientSecret used in the example are not real keys and should be replaced with real ones.

<!DOCTYPE html>
<meta charset="utf-8" />
<title>WebSocket Test</title>
<script language="javascript" type="text/javascript">
var wsUri = "wss://streams.richrelevance.com/upsevents/api/v2/service/UserProfileStream/4faeaf752ee40a0f?clientApiKey=b0126f995ac848159d&clientSecret=wbhz6c41";


var output;


function init() {
output = document.getElementById("output");
testWebSocket();
}


function testWebSocket() {
websocket = new WebSocket(wsUri);
websocket.onopen = function(evt) {
onOpen(evt)
};
websocket.onclose = function(evt) {
onClose(evt)
};
websocket.onmessage = function(evt) {
onMessage(evt)
};
websocket.onerror = function(evt) {
onError(evt)
};
}


function onOpen(evt) {
writeToScreen("CONNECTED");
}


function onClose(evt) {
writeToScreen("DISCONNECTED");
}


function onMessage(evt) {


var str = evt.data;
writeToScreen('<span style="color: blue;">RESPONSE: ' + str + '</span>');
}


function onError(evt) {
var str = evt.data;
writeToScreen('<span style="color: red;">ERROR:</span> ' + str);
}


function doSend(message) {
writeToScreen("SENT: " + message);
websocket.send(message);
}


function writeToScreen(message) {
var pre = document.createElement("p");
pre.style.wordWrap = "break-word";
pre.innerHTML = message;


output.insertBefore(pre, output.firstChild);
}


window.addEventListener("load", init, false);
</script>
<h2>WebSocket Test</h2>
<div id="output"></div>

Sample Request

wss://streams.richrelevance.com/upsevents/api/v2/service/UserProfileStream/4faeaf752ee40a0f?clientApiKey=b0126f995ac848159d&clientSecret=wbhz6c41

Returns one message for each event streaming to the User Profile Service for
ApiKey = 4faeaf752ee40a0f
clientApiKey = b0126f995ac848159d
clientSecret = wbhz6c41

 

Sample Response

The response will be a stream of events. We’ve listed two to keep it concise.

{
  "apiKey":"4faeaf752ee40a0f ",
  "userId":"3280816",
  "sessionId":"a40fa0ce-f3d1-49c9-94f2-24f676070c02",
  "rrUserId":"1a76f643-9dbb-4fed-9080-a35325605c51",
  "eventType":"itemView",
  "viewedItem":"132926",
  "eventTime":1428681303249
}
{
  "apiKey":"4faeaf752ee40a0f ",
  "userId":"",
  "sessionId":"c0781430-a5a7-4cab-9122-763e8cb18ac0",
  "rrUserId":"2a045a50-1d92-4326-eca0-905328ff0440",
  "eventType":"referredFromSite",
  "referrerUrl":"https://www.google.com/",
  "eventTime":1428681305798
}

 

Event Types

The response received will be events that correspond to the various fields in the UPS and are documented below. Each event is a JSON document and contains an eventType field that describes the type of event.

More of the fields in the objects are shared between all event types. The common fields are:

  • apiKey: Your api key.
  • userId: The user id of the user action that created the event.
  • sessionId: The session is of the user action that created the event.
  • rrUserId: The RR user id of the user action that created the event. Not all events will have a rrUserId.
  • eventType: describes the type of event.
  • eventTime: The time of the event in milliseconds since midnight Jan1 1970. UTC.

Examples of each individual event type are given below

BrandView:
The user viewed a brand page. The brand is in the viewedBrand field

{
"apiKey" : "123",
"userId" : "user1",
"sessionId" : "sess1",
"rrUserId" : "rr7",
"eventType" : "brandView",
"viewedBrand" : "brand1",
"eventTime" : 1428614744057
}

CategoryView
The user viewed a category page. The category id is in the viewedCategory field

{
"apiKey" : "123",
"userId" : "user1",
"sessionId" : "sess1",
"rrUserId" : "rr7",
"eventType" : "categoryView",
"viewedCategory" : "cat123",
"eventTime" : 1428614744057
}

ItemClick
The user clicked on recommendation of a product. The product id is in the clickProductId field.

{
"apiKey" : "123",
"userId" : "user1",
"sessionId" : "sess1",
"rrUserId" : "rr7",
"eventType" : "itemClick",
"eventTime" : 1428614744057,
"clickProductId" : "item123"
}

AddToCart
The user added one or more products to the cart. The product information is in the addedToCartItems field that contains an array of line items.
Each line item contains a product, quantity and price in cents.

{
"apiKey" : "123",
"userId" : "user1",
"sessionId" : "sess1",
"rrUserId" : "rr7",
"eventType" : "addedToCart",
"addedToCartItems" : [ {
                        "itemId" : "item123",
                        "priceCents" : 1099,
                        "quantity" : 1
                       },
                       {
                        "itemId" : "item456",
                        "priceCents" : 2399,
                        "quantity" : 2
                        } ],
"eventTime" : 1428614744057
}

Purchase
The user purchased one or more products. The product information is in the orders field that contains an array of line items. Each line item contains a product, quantity and price in cents.

{
"apiKey" : "123",
"userId" : "user1",
"sessionId" : "sess1",
"rrUserId" : "rr7",
"eventType" : "order",
"orders" : [ {
              "itemId" : "item123",
              "priceCents" : 1099,
              "quantity" : 1
             },
             {
              "itemId" : "item456",
              "priceCents" : 2399,
              "quantity" : 2
             } ],
"eventTime" : 1428614744057
}

Search
The user performed a search. The searchTerm field contains the string the user searched for.

{
"apiKey" : "123",
"userId" : "user1",
"sessionId" : "sess1",
"rrUserId" : "rr7",
"eventType" : "search",
"searchTerm" : "where is it",
"eventTime" : 1428614744057
}

Opt Out
The user opted out or opted in. The enableOptOut field contains true if opt out, false if opt in.

{
"apiKey" : "123",
"userId" : "user1",
"sessionId" : "sess1",
"rrUserId" : "rr7",
"eventType" : "search",
"enableOptOut" : true,
"eventTime" : 1428614744057
}

 

  • Was this article helpful?