Einstein Recommendation Collect Tracking API

Overview 

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.

1https://MID.collect.igodigital.com/c2/MID/track_page_view.json
2{
3    "payload": {
4        "title": "INSERT_PAGE_TITLE",
5        "url": "INSERT_PAGE_URL",
6        "referrer": "INSERT_REFERRER_URL",
7        "user_info": {
8            "email": "INSERT_EMAIL_OR_SUBSCRIBER_ID"
9        }
10    },
11    "user_id": "",
12    "session_id": ""
13}

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.

1https://MID.collect.igodigital.com/c2/MID/track_page_view.json
2{
3    "payload": {
4        "item": "INSERT_ITEM",
5        "user_info": {
6            "email": "INSERT_EMAIL_OR_SUBSCRIBER_ID"
7        },
8    "user_id": "",
9    "session_id": ""
10    }
11}

Additional Parameter Definitions 

item 

Represents the item that’s being displayed to the customer, such as on an item detail page.

Real-Time Rating Collect Example 

This example implements an observation script that tracks when a user submits a rating for an item.

1https://MID.collect.igodigital.com/c2/MID/track_rating.json?
2{
3    "payload": {
4        "item": "INSERT_ITEM",
5        "rating": "INSERT_ITEM_RATING",
6        "user_info": {
7            "email": "INSERT_EMAIL_OR_SUBSCRIBER_ID"
8        }
9    },
10    "user_id": "",
11    "session_id": ""
12}

Additional Parameter Definitions 

rating 

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.

1https://MID.collect.igodigital.com/c2/MID/track_cart.json?
2{
3    "payload": {
4        "cart": [
5            {
6                "item": "INSERT_ITEM",
7                "quantity": "INSERT_QUANTITY",
8                "price": "INSERT_ITEM_PRICE",
9                "unique_id": "INSERT_UNIQUE_ID"
10            },
11            {
12                "item": "INSERT_ITEM",
13                "quantity": "INSERT_QUANTITY",
14                "price": "INSERT_ITEM_PRICE",
15                "unique_id": "INSERT_UNIQUE_ID"
16            }
17        ],
18        "user_info": {
19            "email": "INSERT_EMAIL_OR_SUBSCRIBER_ID"
20        }
21    },
22    "user_id": "",
23    "session_id": ""
24}

Additional Parameter Definitions 

item 

Set this parameter to a unique identifier for the item in the user’s cart.

quantity 

Set this parameter to the quantity of the item in the user’s cart.

price 

Set this parameter to the per-unit price of the item in the user’s cart.

Clear Cart Collect Example 

This example implements an observation script that indicates when the user has emptied their shopping cart.

1https://MID.collect.igodigital.com/c2/MID/track_cart.json?
2{
3    "payload": {
4        "cart": {
5            "clear_cart": true
6        },
7        "user_info": {
8            "email": "INSERT_EMAIL_OR_SUBSCRIBER_ID"
9        }
10    },
11    "user_id": "",
12    "session_id": ""
13}

Additional Parameter Definitions 

clear_cart 

When true, indicates that the user has removed all items from their shopping cart.

Conversion Collect Example 

This example implements an observation script that tracks a conversion event.

1https://MID.collect.igodigital.com/c2/MID/track_conversion.json?
2{
3    "payload": {
4        "cart": [
5            {
6                "item": "INSERT_ITEM",
7                "quantity": "INSERT_QUANTITY",
8                "price": "INSERT_ITEM_PRICE"
9            },
10            {
11                "item": "INSERT_ITEM",
12                "quantity": "INSERT_QUANTITY",
13                "price": "INSERT_ITEM_PRICE"
14            }
15        ],
16        "user_info": {
17            "email": "INSERT_EMAIL_OR_SUBSCRIBER_ID"
18        },
19        "order_number": "INSERT_ORDER_NUMBER",
20        "shipping": "INSERT_SHIPPING_CHARGE",
21        "discount": "INSERT_DISCOUNT_AMOUNT"
22    },
23    "user_id": "",
24    "session_id": ""
25}

Additional Parameter Definitions 

order_number 

Set this parameter to the order number after a conversion event occurs.

shipping 

This optional parameter specifies the shipping charge associated with the user’s order.

discount 

This optional parameter specifies the discount amount that was applied to the user’s order.

Search Collect Example 

This example implements an observation script that tracks page views for a specific item detail page.

1https://MID.collect.igodigital.com/c2/MID/track_page_view.json?
2{
3    "payload": {
4        "search": "INSERT_SEARCH_TERM",
5        "title": "INSERT_PAGE_TITLE",
6        "url": "INSERT_PAGE_URL",
7        "referrer": "INSERT_REFERRER_URL",
8        "user_info": {
9            "email": "INSERT_EMAIL_OR_SUBSCRIBER_ID"
10        }
11    },
12    "user_id": "",
13    "session_id": ""
14}

Additional Parameter Definitions 

search 

Set this parameter to include the internal or external search keywords that led to the page view event.

Category Page Collect Example 

This example implements an observation script that tracks page views for a specific item detail page.

1https://MID.collect.igodigital.com/c2/MID/track_page_view.json?
2{
3    "payload": {
4        "category": "INSERT_CATEGORY_NAME",
5        "title": "INSERT_PAGE_TITLE",
6        "url": "INSERT_PAGE_URL",
7        "referrer": "INSERT_REFERRER_URL",
8        "user_info": {
9            "email": "INSERT_EMAIL_OR_SUBSCRIBER_ID"
10        }
11    },
12    "user_id": "",
13    "session_id": ""
14}

Additional Parameter Definitions 

category 

Set this parameter for each category and subcategory page.

Example Response 

1{
2user_id: "5fb6fd46-7fd6-11e4-93db-123139337486"
3session_id: "5fb70c14-7fd6-11e4-93db-123139337486"
4}

Create or Update a Single Item Example 

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.

1https://MID.collect.igodigital.com/c2/MID/update_item_secure.json?api_key=<api_key>
2{"payload":
3	{
4		"item": "INSERT_ITEM",
5		"unique_id": "INSERT_UNIQUE_ITEM_ID",
6		"item_type": "INSERT_ITEM_TYPE",
7		"name": "INSERT_ITEM_NAME_OR_TITLE",
8		"INSERT_ATTRIBUTE_NAME": "INSERT_ATTRIBUTE_VALUE"
9	}
10}

Create or Update Multiple Items Example 

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.

1https://MID.collect.igodigital.com/c2/MID/update_item_secure.json?api_key=<api_key>
2{"payload":
3   [
4      {
5	   "item": "INSERT_ITEM",
6	   "item_type": "INSERT_ITEM_TYPE",
7	   "name": "INSERT_ITEM_NAME_OR_TITLE",
8	   "INSERT_ATTRIBUTE_NAME": "INSERT_ATTRIBUTE_VALUE"
9      },
10      {
11	   "item": "INSERT_ITEM",
12	   "item_type": "INSERT_ITEM_TYPE",
13	   "name": "INSERT_ITEM_NAME_OR_TITLE",
14	   "INSERT_ATTRIBUTE_NAME": "INSERT_ATTRIBUTE_VALUE"
15      }
16   ]
17}

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.

1{
2    "payload": {
3        "item": "INSERT_ITEM",
4        "item_type": "INSERT_ITEM_TYPE",
5        "name": "INSERT_ITEM_NAME_OR_TITLE",
6        "INSERT_ATTRIBUTE_NAME": [
7            "INSERT_ATTRIBUTE_VALUE1",
8            "INSERT_ATTRIBUTE_VALUE2",
9            "INSERT_ATTRIBUTE_VALUE3"
10        ]
11    }
12}

Update Item Availability Example 

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.

1https://MID.collect.igodigital.com/api/update_product?key=<API_KEY>&sku=INSERT_UNIQUE_ITEM_ID&availability=N