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. 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 extractOrder method
  2. Event-Based: Subscribe to the ORDER_EXTRACTED event to receive order information automatically
Order extraction is only supported on cart, checkout, and checkoutComplete.

Manual Extraction

To extract order information from an cart, checkout or order confirmation page, you can use the extractOrder method:
<script src="f.js"></script>
<script src="sdk.iife.js"></script>
<script>
  sleek.initializeSdk("YOUR_PUBLIC_API_KEY_HERE");

  const order = await sleek.getSdk().extractOrder(); // Returns Promise<ExtractOrderResult>
</script>
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 classifyPage method. See the page classification guide for more information.

Event-Based Extraction

Alternatively, you can receive order information automatically by subscribing to the ORDER_EXTRACTED event. This requires to set emitPageClassification to true in the SDK’s options during initialization.
<script src="f.js"></script>
<script src="sdk.iife.js"></script>
<script>
  sleek.initializeSdk("YOUR_PUBLIC_API_KEY_HERE", {
    featureControls: {
      emitOrders: true,
    },
  },
  [
    (event) => {
      // `event` is typed, so is the data of the event `event.data` based on the type of the event.
      switch (event.type) {
        case SdkEventType.ORDER_EXTRACTED:
          const order = event.data.order;
          const classification = event.data.pageClassification;
          break;
      }
    }
  ]);
</script>

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: Product[] | null;
};
What’s next: Now that you have enabled order extraction, you can check out the TypeDoc for specific event types and methods on the SDK.

View TypeDoc

Browse the reference TypeDoc for the SDK.