Upload interactions

Upload user interaction events to Miso dataset.


Syntax

await client.api.interactions.upload(events, options);

Parameters

The events parameter can be:

  • An object, representing a single user interaction event
  • An array of objects, representing multiple events
  • A JSON string of array of objects

A single record of event object can have the following properties depending on the event type:

Select an event type:

Name Type Description
type string Required. The type of event.
custom_action_name string Required. The name of the custom interaction that you have defined.
user_id string Identifies the signed-in user who performed the interaction. We will use user_id to link Interaction records to your User records. For visitors who have not signed in, see anonymous_id.
anonymous_id string A pseudo-unique substitute for user_id. We use anonymous_id to identify a visitor who has not signed in. When a visitor signs in and the user_id and anonymous_id are both present, the anonymous_id will be linked to the user_id along with the past interactions associated with it.
category array of strings A hierarchical list describing the product category. For example, ['home', 'kitchen', 'tools'].
search object The search keywords and filters the user uses.
revenue object Total revenue associated with the checkout. The revenue should include generally shipping, tax, etc. that you want to include as part of your revenue calculations.
quantities array of positive integers The quantities of products the user adds to their cart or checks out with.
rating number The rating the user gave in the range of [0, 5]. As a convention in the RecSys community, a rating >= 3.5 is considered positive, a rating <= 2 is negative, and otherwise a rating is neutral. If you use any other rating scale, please normalize it to a [0, 5] scale.
duration number How long (in seconds) the user stayed on this page, or consumed (listened, read, or watched) a product.
product_ids array of strings Products or content the user is interacting with. Default: []
product_group_ids array of strings The product groups the user is interacting with.
timestamp string The ISO-8601 timestamp specifying when the interaction occurred. If the interaction just happened, leave it out and we will default to the server's time.
miso_id string Miso-generated unique Id for each recommendation or search result.
context object An object of extra information that provides useful context about an interaction.

Options

The options parameter is an optional object with the following properties:

Name Type Description
dryRun boolean Make a dry run with upload APIs. Default: false.

See the request options page for more details.

Return value

A Promise without value.

Examples

const event = {
type: 'add_to_cart',
product_ids: ['a001', 'a002'],
quantities: [3, 5],
user_id: '...'
};
await client.api.interactions.upload(event);

Learn more

For more information, see REST API.