Einstein Recommendation Collect Tracking API
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.
A unique client identifier. This value is typically the MID associated with the Business Unit.
The title of the page that the user is viewing.
The URL or path to the application page.
The previous page or referring URL for the application.
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.
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.
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.
This example shows how to implement an observation script that tracks views for a specific item detail page.
Represents the item that’s being displayed to the customer, such as on an item detail page.
This example implements an observation script that tracks when a user submits a rating for an item.
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.
This example implements an observation script that tracks a snapshot of the items in the user’s cart.
Set this parameter to a unique identifier for the item in the user’s cart.
Set this parameter to the quantity of the item in the user’s cart.
Set this parameter to the per-unit price of the item in the user’s cart.
This example implements an observation script that indicates when the user has emptied their shopping cart.
When true, indicates that the user has removed all items from their shopping cart.
This example implements an observation script that tracks a conversion event.
Set this parameter to the order number after a conversion event occurs.
This optional parameter specifies the shipping charge associated with the user’s order.
This optional parameter specifies the discount amount that was applied to the user’s order.
This example implements an observation script that tracks page views for a specific item detail page.
Set this parameter to include the internal or external search keywords that led to the page view event.
This example implements an observation script that tracks page views for a specific item detail page.
Set this parameter for each category and subcategory page.
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
.