User Context

Created by Pedro Ondiviela · last update June 3, 2020

What is this about?

Returns the top product attributes and the last visited specific products for a specific user and session. While “userPreferences” are query-agnostic, “userLastViewedProducts” are returned for the specific query requested.

The product attribute preferences are calculated based on user clicks, add-to-carts and purchases and the values are normalized using a linear function.

userLastViewedProducts” weight is calculated using the difference between the last time there was an interaction with the product and “now”. So, the more recent events will have more weight than others that happened long ago.

About this Endpoint

Structure for calling the endpoint.

Request URL example

GET https://api.empathybroker.com/contextsearch/v2/usercontext/all/{instance_id}?{Input_Parameters}

Input Parameters

Parameter name Data Type
Required:  
user String
query String
Not required:  
session String
preferences.rows Integer
last_products.rows Integer
session.preferences.rows Integer
session.last_products.rows Integer


Responses

Responses examples for successful and failing calls to the endpoint.

userPreferences” objects don’t have a fixed order and it may change in between requests. Nevertheless, values for each preference are sorted by “weight” in descending order.

Remember that your EB Contextualize configuration could use different fields for the preferences calculations, so the ones showing aside (“brand” and “gender”) are just examples.

200 400 404

Successful request

Type: application/json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{
  "userPreferences": [
    {
      "field":"brand",
      "values": [
        {"value":"apple","weight":3},
        {"value":"sony","weight":2.1}
      ]
    },
    {
      "field":"gender",
      "values": [
        {"value":"woman","weight":3}
      ]
    }
  ],
  "sessionPreferences": [
    {
      "field":"brand",
      "values": [
        {"value":"apple","weight":3}
      ]
    },
    {
      "field":"gender",
      "values": [
        {"value":"woman","weight":3}
      ]
    }
  ],
  "userLastViewedProducts": [
    {"value":"213115", weight:3},
    {"value":"213149", weight:1.3}
  ],
  "sessionLastViewedProducts": [
    {"value":"213142", weight:3}
  ]
}