Rebuy Analytic 2.0 Endpoints

Endpoints for creating analytics for use in Rebuy tools such as the Recently Viewed widget.

Endpoints

Event

  • Single Event
    • POST https://rebuyengine.com/api/v2/analytics/event
    • Required headers
      • X-Rebuy-User-Token value: Your key to use our API
      • Content-Type value: "application/json"
    • Request creates a single analytic event
    • {
        "subject": "user",
        "verb": "viewed",
        "noun": "product",
        "uuid": "be6f5fab-32a4-43e5-967c-68017baa3aa5", // example UUID
        "customer_id": "65069794", // example customer id
        "product_id": "5630650697948" // example product id
      }
      
      {
          "data": "Received"
      }
      
  • Fields
    • subject string (required)
      The subject of the event. Supported value: [user].
    • verb string (required)
      The action of the subject of the event. Supported values: [viewed, added, removed].
    • noun string (required)
      The object that the subject's action operated upon. Supported value: [product].
    • product_id string (required)
      The unique identifier of the noun field. Even if numeric this must be passed as a string
    • product_handle string (required if product id is not available)
      The product handle can be passed in lieu of the product id if the noun is "product"
    • customer_id string
      The customer id can be passed to tie multiple UUIDs from different browsers together if the UUID for a customer is being stored in a cookie. Even if numeric this must be passed as a string
    • theme_id string
      The theme identifier that applies to the product
    • uuid string (required)
      The 'Universally Unique Identifier' of the subject - the client is responsible for creating the token that represents the session. We recommend using this NPM package (https://www.npmjs.com/package/uuid). Example value: be6f5fab-32a4-43e5-967c-68017baa3aa5
    • platform string
      Commerce platform identification string. Default: "Shopify"

How to use the endpoint

  1. Generate a UUID for the customer if one hasn't been created already.
  2. Build your POST data with the appropriate subject, verb, and noun (ex. user, viewed, product) and corresponding product data (ex. product_id)
  3. Submit your request when a customer views a product.

Once you've submitted data to this endpoint, you can call the /products/viewed endpoint using the customer's established UUID to get a list of products that they've viewed throughout their session.

Bulk Events

  • Multiple Events (maximum of 100 items)
    • POST https://rebuyengine.com/api/v2/analytics/event/bulk
    • Required headers
      • X-Rebuy-User-Token value: Your key to use our API
      • Content-Type value: "application/json"
    • Request creates a single analytic event
    • [
        // event 1
        {
          "subject": "user",
          "verb": "viewed",
          "noun": "product",
          "uuid": "be6f5fab-32a4-43e5-967c-68017baa3aa5", // example UUID
          "customer_id": "65069794", // example customer id
          "product_id": "5630650697948" // example product id
        },
        // event 2
        {
          "subject": "user",
          "verb": "viewed",
          "noun": "product",
          "uuid": "be6f5fab-32a4-43e5-967c-68017baa3aa5", // example UUID
          "customer_id": "65069794", // example customer id
          "product_id": "6506975630948" // example product id
        },
      ]
      
      {
          "data": "Received"
      }
      
  • Fields
    • The same fields as required for the single event endpoint

How to use the endpoint

  1. The general structure and usage is similar to the single event endpoint, however, up to one hundred JSON events can be passed inside of a JSON array
  2. Each event must contain all required fields

Reference

UUID Generation

🚧

Generating a client-side UUID

At this time, the client is responsible for generating a UUID to be included with the request.

We recommend using this NPM package (UUID) to generate the UUID.

We also recommend storing this session-based UUID if you plan on using the /products/viewed endpoint.