Skip to main content

The context request object

Abstract

Describes the structure and properties of the context object in a Search and Recommendation request.

Use a context object to specify the types of context you want to retrieve in the response. You can add different <context_types> in your request, such as information about the user, browser, geographic location, store, fitment, page, campaign, and channel to make results more relevant.

The following shows the basic structure of a context object in a request:

{
    "context": {
	"<context_type>": {
            "<context_key>": {<context_key_values>}
	}
    }
}

The following table describes the keys that the context object contains:

Key

Type

Description

Values

context_type

Context type object

Optional.

Contains the supported context object type.

You can have more than one context_type.

  • channel

  • campaign

  • page

  • fitment

  • store

  • geo

  • browser

  • user

context_key

array

Optional.

Contains the <context_key_values> that correspond to the fields in each context object type.

You can have more than one context_key.

n/a

Context type objects

The following table describes the supported context objects:

Object

Type

Description

user

User context object

User details including IDs, gender, email address, and group.

browser

Browser context object

User device or browser information.

geo

Geo context object

User location including geographic information and IP address.

store

Store context object

Store ID associated with the user.

fitment

Fitment context object

User fitment information.

page

Page context object

Page details including URL, title, IDs, list of products, and locale information.

campaign

Campaign context object

Campaign information including utm_source and utm_campaign.

channel

Channel context object

Channel information.

In this example, you apply a user context for gender:

}

{
  "query": {
    "keyphrase": [["red", "shorts"]]
  },
  "n_item": 3,,
  "content": {},
  "context": {
    "user": {
      "gender": "female"
    }
  }