You can implement Einstein Recommendation Collect Tracking calls by making a POST request to the appropriate URL.
When you issue your first request to the Collect API, the JSON response includes user_id and session_id values. You can use these values in subsequent calls. Include these parameters at the same level as the payload, as shown in this basic example.
Keep these considerations in mind when you use the Collect API.
The Collect API only accepts requests that use the Content-Type: application/json header.
You can issue requests to HTTP or HTTPS endpoints.
An API key is only required when you issue a request that creates or updates product or catalog data via Streaming Updates.
Parameter Definitions
MID
A unique client identifier. This value is typically the MID associated with the Business Unit.
title
The title of the page that the user is viewing.
url
The URL or path to the application page.
referrer
The previous page or referring URL for the application.
email
Include this value if the site is tracking the user’s email address or other identifier. For example, on pages such as newsletter signup pages or order confirmation pages, you typically have the user’s email address.
The Collect API uses email addresses to merge duplicate values.
user_id
The user_id value returned from the first Collect API call for an individual user. Use this value for all future API calls for that individual.
When you start a new session, a new profile is created. At the end of the session, if there are multiple records that share a common email address, those records are merged.
Note
session_id
The session_id value returned from the first Collect API call for the user’s current session. Use this value for all API calls in an individual’s session.
Item Detail View Collect Example
This example shows how to implement an observation script that tracks views for a specific item detail page.
Populate this parameter with a numerical representation of the rating that the user submitted. You must pass this value in the same call for the rating to be properly recorded.
Cart Collect Example
This example implements an observation script that tracks a snapshot of the items in the user’s cart.
This code sample implements streaming updates to a single item in your catalog.
Replace the placeholder values with dynamic code to get the appropriate value for the item. Acceptable values for item_type are content, product, or banner. If your request doesn’t specify a value for item_type, or it provides a value that the API doesn’t recognize, the API uses a default value of content.
This code sample updates multiple items in your catalog.
Replace the placeholder values with dynamic code to get the appropriate value for the item. Acceptable values for item_type are content, product, or banner. If your request doesn’t specify a value for item_type, or it provides a value that the API doesn’t recognize, the API uses a default value of content.
Attributes can include multiple values. To specify an attribute that has multiple values, place the values in a string array, as shown in this code sample.
You can use the API to update the availability of an item in your catalog. Set the value of sku to a unique ID for the item that you’re modifying. The availability parameter indicates whether the product is available. Acceptable values for availability are Y or N.