Commerce Insights Event API

Overview

The Commerce Insights Events service accepts your e-commerce platform events for generating Commerce Insights reports and insights.

You can use these APIs to send:

  • Cart create, update, and delete events
  • Product create, update, and delete events
  • Order create, update, and delete events
  • Customer create, update, and delete events
  • Batch create, update, and delete events
  • Heartbeat events
  • Test events

For more information about Commerce Insights, see:


API Reference

/{partner_site_id}/site_check

For new clients, use this endpoint to test your events. It is a NOOP (No Operation command) and no side effects occur when sending this.

/{partner_site_id}/site_check

post

Send NOOP(s).

/{partner_site_id}/heartbeat

Send your site's heartbeats to Commerce Insights.

/{partner_site_id}/heartbeat

post

Send your site's heartbeats to Commerce Insights.

/{partner_site_id}/batch

Send more than one cart, order, product, customer, category event to Commerce Insight.

/{partner_site_id}/batch

post

Send more than one cart, order, product, customer, category event to Commerce Insight.

/{partner_site_id}/cart

Send a cart event to Commerce Insights.

/{partner_site_id}/cart

post

Send a cart event to Commerce Insights.

/{partner_site_id}/order

Send a order event to Commerce Insights.

/{partner_site_id}/order

post

Send a order event to Commerce Insights.

/{partner_site_id}/product

Send a product event to Commerce Insights.

/{partner_site_id}/product

post

Send a product event to Commerce Insights.

/{partner_site_id}/customer

Send a customer event to Commerce Insights.

/{partner_site_id}/customer

post

Send a customer event to Commerce Insights.

/{partner_site_id}/category

Add, update, and delete the merchandise categories for your product catalog.

/{partner_site_id}/category

post

Send a category event to Commerce Insights

/{partner_site_id}/config

Retrieve your site's tracker URL

/{partner_site_id}/config

get

Retrieve your site's tracker URL


Scopes

Scopes are strings that let you specify exactly what type of access you need to resources and operations in the Commerce Insights Event service.

You must provide a proper scope that allows users to perform certain operations. Grant the scopes in an access token from the OAuth 2.0 service. For more information about the authorization and authentication used in SAP Hybris services, and also about the scopes in general, see: Authorization Scopes

The Commerce Insights Event service does not use scopes.


Heartbeat Events

The Commerce Insights API supports a /heartbeat endpoint that allows you to ping the Commerce Insights platform at a specified interval, ensuring that your module is running and able to reach the Commerce Insights platform. This is a good practice to manage uptime and is helpful in case of low transaction volumes. Your application should ping the endpoint every 30 minutes. Do not configure the ping operation in a system-level cron, as that will only tell the service that the box is up.


Product Events

For every product event, such as add, edit, and delete, send a product event to the Commerce Insights platform.

Because merchants have various degrees of product and merchandise set-ups ranging from standard products, parent products, to SKUs and configurable products, the Commerce Insights product object is built flexibly to account for the set-up that makes the most sense for your business.

  • Simple product - In many cases, you might need a simple product, for example, if you sell a stand-alone product such as a CD player. In this case, set the product object to is_product=True and is_SKU=True. There is no base product.

  • Base product - If you have configurable or variant products, use a base product that represents most of the parent group products. For example, if you sell red, blue, and green shirts, the shirt itself is the base product. In this case, set the base product to is_product=True and is_SKU=False.

  • Configurable or variant product - For each of these product types, reference the base product per the schema, setting is_product=False and is_SKU=True. For each, include the respective attributes, such as red, blue, and green, to provide the SKU-level attribute detail.

    In certain cases, your system might support the ability to have multiple levels of variant inheritance. In that case, provide the correct product and SKU mapping.


Cart Events

Your e-commerce platform should send events whenever a customer adds, removes, or alters the cart. Do not push old or historical cart data because carts are analyzed only on a forward-going basis.

For Commerce Insights to process your cart events push both current cart items as well as previous cart items. See the examples below.

Examples

Scenario 1: Add one item to cart. For example, one pair of socks.

items:[
  {prod:'socks', qty:1}
]

Scenario 2: Add two more items to an existing cart. For example, add two pairs of shoes.

items:[
  {prod: 'socks', qty: 1},
  {prod: 'shoes', qty: 2}
],
previous_items[
  {prod:'socks', qty: 1}
]

Scenario 3: Remove items from an existing cart. For example, remove one pair of socks and one pair of shoes.

items:[
  {prod: 'shoes', qty: 1}
],
previous_items[
  {prod: 'socks', qty: 1},
  {prod: 'shoes', qty: 2}
]


Order Events

The orders endpoint accepts your past and current order details. The orders endpoint accepts your changes to orders. Be sure to push all of your historical order data. The /batch endpoint is ideal for pushing this information efficiently.

There are three types of order events:

  • Order placed
  • Order accepted
  • Order cancelled

Order placed event

This event ties the web visitor ID to your orders. To create the order-placed event:

  • Set the status key to placed.
  • Connect website visitors' behavior to order events by adding the JSON key visit and object with the following schema:
visit: {
    "visit_id"         : 'vid',
    "visitor_id"       : 'vis',
    "pageview_id"      : 'pvid',
    "last_pageview_id" : 'lpvid'
}

Example order placed event:

{
  "order_number": "123456789",
  "cart_id": "123456789",
  "status": "placed",
  "order_date": "2013-06-17T15:16:10.000Z",
  "customer": {
      "id": "abc123",
      "create_date": "2013-06-17T15:16:11.000Z",
      "change_date": "2013-06-17T15:16:11.000Z",
      "email": "foo@example.com",
      "first_name": "Jane",
      "last_name": "Doe"
  },
  "visit": {
      "visit_id": "1234",
      "visitor_id": "4321",
      "pageview_id": "5678",
      "last_pageview_id": "8765"
  }
}

See the Order event usage tutorial for instructions on how to set the values for this object.

Order accepted event

This event describes the order details including:

  • line items
  • products
  • order date, total, taxes, shipping, and more
  • product images
  • order adjustments

This event also handles order changes. See the Order event usage tutorial for instructions on how to use this event.

Order accepted event example:

{
  "order_number": "8797436543019",
  "cart_id": "1234asdf",
  "status": "accepted",
  "order_date": "2013-06-17T15:16:10.000Z",
  "create_date": "2013-06-17T15:16:10.000Z",
  "change_date": "2013-06-17T15:16:15.000Z",
  "subtotal": 99.85,
  "total": 99.85,
  "total_tax": 4.75,
  "total_shipping": 0.0,
  "total_payment_cost": 0.0,
  "total_discounts": 0.0,
  "currency": "USD",
  "delivery_address": {
    "postalcode": "12345",
    "address1": "123 Main St.",
    "country": "US",
    "state": "New York",
    "id": "8797680173079",
    "city": "Anytown"
  },
  "payment_address": {
    "postalcode": "12345",
    "address1": "123 Main St.",
    "country": "US",
    "state": "New York",
    "id": "8797680238615",
    "city": "Anytown"
  },
  "items": [
      {
          "id": "8797371007020",
          "create_date": "2013-06-17T15:16:11.000Z",
          "change_date": "2013-06-17T15:16:11.000Z",
          "status": "accepted",
          "order_item_number": "1",
          "quantity": 1,
          "price": 99.85,
          "discount_price": 0.0,
          "status": "accepted",
          "product": {
              "id": "8796107014145",
              "create_date": "2013-03-28T19:46:39.000Z",
              "change_date": "2013-03-28T19:50:58.000Z",
              "is_product": true,
              "is_sku": true,
              "catalog": {
                  "id": "electronicsProductCatalog",
                  "name": "Electronics Product Catalog"
              },
              "name": "PowerShot A480",
              "code": "1934793",
              "brand": "Canon",
              "categories": [
                  {
                      "id": "8796098461838",
                      "name": "Digital Compacts"
                  },
                  {
                      "id": "8796099248270",
                      "name": "Canon"
                  }
              ],
              "images": [
                  {
                      "url": "http://yourstore.com/images/the_photo.jpg"
                  }
              ]
          }
      }
  ],
  "previous_items": [
  ],
  "customer": {
      "id": "abc123",
      "create_date": "2013-06-17T15:16:11.000Z",
      "change_date": "2013-06-17T15:16:11.000Z",
      "email": "foo@example.com",
      "first_name": "Jane",
      "last_name": "Doe"
  }
}

Order cancelled event

This event sets an order status to canceled.

Order canceled example:

{
  "order_number": "123456789",
  "cancel_date": "2013-06-17T15:16:10.000Z",
  "status": "cancelled"
}

Usage

For Commerce Insights to process your order events, do the following:

  • Send the order-placed event first.
  • Send the order-accepted event next, with all of the information about the order after the customer authorizes the order and pays.
  • Anytime the order items change, send the order-accepted event again, with the items contained in the new order, and the previous_items parameter that shows the items in the previous order.
  • Send the order-cancelled event if the customer cancels the entire order.

Example scenarios

Scenario 1: Add one item to a new order. For example, add one pair of socks.

items:[
    {prod:'socks',qty:1}
]

Scenario 2: Add two more items to an existing order. For example, add two pairs of shoes.

items:[
    {prod:'socks',qty:1},
    {prod:'shoes',qty:2}
],
previous_items[
    {prod:'socks',qty:1}
]

Scenario 3: Remove items from an existing order. For example, remove one pair of socks and one pair of shoes.

items:[
    {prod:'shoes',qty:1}
],
previous_items[
    {prod:'socks',qty:1},
    {prod:'shoes',qty:2}
]


Customer Events

You can use these properties to add, update, and delete customer data in the Commerce Insight Events service.

  • Cookies
  • Email
  • Name
  • Phone
  • Active flag
  • Company
  • Department
  • Position
  • Marketing opt-in


Batch Events

Use this endpoint to send more than one Cart, Product, Order, or Customer service event in one request.

This endpoint allows the submittal of up to 10MB of events in a single request.


Setting visitor JSON object

The Commerce Insights tracker stores visitor and visit identifiers in cookies. To connect web visitors and activity to your e-commerce platform events, link the data stored by the Commerce Insights tracker with your e-commerce platform event by setting the visitor JSON object. Only the cart and order placed events require setting the visit JSON object. The following table describes the mapping to make for generating the visit object for those two events:

Commerce Insights cookievisit JSON object
_vidvisit_id
_visvisitor_id


Glossary

TermDescription
attributionAn assignment of credit for sales in conversion paths.
Commerce InsightsThe e-commerce analytics and insights application/platform
conversion rateThe rate at which your visitors convert to purchase.
insightsA high-level analysis of your data with calls to action.
pageviewCount of web pages viewed including all text and images.
skuStock Keeping Unit
visitAn individual visitor who arrives at your site. A visitor browsing multiple pages counts as one visit.


  • Send feedback

    If you find any information that is unclear or incorrect, please let us know so that we can improve the Dev Portal content.

  • Get Help

    Use our private help channel. Receive updates over email and contact our specialists directly.

  • hybris Experts

    If you need more information about this topic, visit hybris Experts to post your own question and interact with our community and experts.