Sleek’s SDK can extract order details from pages your users are visiting. This feature allows you to capture successful transactions and order details. This documentation will guide you through the integration process.
This document assumes that you have already integrated the Sleek SDK into your extension. If you haven’t, please refer to the SDK integration guide.

Enable order extraction

There are two ways to get order information from Sleek:
  1. Manual Extraction: Extract order information from a specific tab using the extractOrderOnTab method
  2. Event-Based: Subscribe to the ORDER_COMPLETED event to receive order information automatically
Note:
  • Manual extraction is supported on pages classified as cart, checkout, or checkoutComplete.
  • Event-based extraction is only supported on checkoutComplete pages.

Manual Extraction

To extract order information from an cart, checkout or order confirmation page, you can use the extractOrderOnTab method:
import { getSdkInstance } from "@sleek/web-ext-coupon-sdk";

const order = await getSdkInstance().extractOrderOnTab(tabId);
// Returns Promise<Order | undefined>
Sleek will only return order information on pages that are classified as cart, checkout or checkoutComplete. To determine the page classification, you can use the classifyPageOnTab method. See the page classification guide for more information.

Event-Based Extraction

Alternatively, you can receive order information automatically by subscribing to the ORDER_COMPLETED event. This requires two steps:
  1. Enable order events in your SDK options:
const sleekSdk = new SleekWebExtCouponSdk(initCallback, apiKey, {
  featureControls: {
    emitOrders: true
  }
});
  1. Register an event listener to receive order information:
sleekSdk.registerEventListener((event, tabId, tabDetails) => {
  if (event.type === "ORDER_COMPLETED") {
    const order = event.data.order;
    // Handle the order information
  }
});
ORDER_COMPLETED events are only emitted on pages classified as checkoutComplete.

Order data structure

The Order object returned by the SDK contains comprehensive information about the order details:
type Order = {
    orderDate: string | null;
    orderNumber: string | null;
    orderTotal: string | null;
    orderSubtotal: string | null;
    orderTax: string | null;
    orderShipping: string | null;
    products: Array<{
        name: string | null;
        price: number | null;
        currencyCode: string | null;
        quantity: number | null;
        imageUrls: string[] | null;
        description: string | null;
        categoryId: string | null;
        categoryBreadcrumb: string | null;
        categoryVersion: string | null;
        brandName: string | null;
        gtin: string | null;
        mpn: string | null;
        sku: string | null;
        asin: string | null;
    }> | null;
};

Events

When the SDK detects that a page is a cart, checkout, or order confirmation page, it emits a PAGE_CLASSIFIED event with the classification set to cart, checkout, or checkoutComplete. You can listen for this event to run your own order-related logic.
What’s next: Now that you have enabled order extraction in your extension, you can check out the TypeDoc for specific event types and methods on the SDK.

View TypeDoc

Browse the reference TypeDoc for the SDK.