> ## Documentation Index
> Fetch the complete documentation index at: https://docs.onsleek.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Page classification

> Specific integration instructions to enable page classification.

Sleek's SDK automatically classifies the pages your users are visiting. To
setup this experience for your users, you'll need to provide Sleek with the
pages that you want to classify. This documentation will guide you through the integration process.

<Warning>
  This document assumes that you have already integrated the Sleek SDK. If you haven't, please refer to the [SDK integration guide](/js-sdk-reference/introduction).
</Warning>

## Enable page classification

After Sleek SDK is installed and setup in your extension, you are ready to enable
page classification.

### Automatically classify pages

To automatically classify pages, set `featureControls.emitPageClassification` to
`true` in the SDK's options during initialization.

<CodeGroup>
  ```html IIFE (via <script>) theme={null}
  <script src="f.js"></script>
  <script src="sdk.iife.js"></script>
  <script>
    sleek.initializeSdk("YOUR_PUBLIC_API_KEY_HERE", {
      featureControls: {
        emitPageClassification: 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.PAGE_CLASSIFIED:
            console.log("Page classification: ", event.data.classification);
            break;
        }
      }
    ]);
  </script>
  ```

  ```typescript CJS / ESM theme={null}
  import { initializeSdk, getSdk } from "@sleek/sdk";

  initializeSdk("YOUR_PUBLIC_API_KEY_HERE", {
    featureControls: {
      emitPageClassification: true,
    },
  },
  [
    (event) => {
      switch (event.type) {
        case SdkEventType.PAGE_CLASSIFIED:
          console.log("Page classification: ", event.data.classification);
          break;
      }
    }
  ]);
  ```
</CodeGroup>

Now that you have enabled page classification, Sleek will automatically classify
the pages your users are visiting and emit the `PAGE_CLASSIFIED` event when a page
has been classified.

### Manually classify pages

In addition to automatic emission of page class, you can manually classify a
page by calling the `classifyPage` method.

<CodeGroup>
  ```html IIFE (via <script>) theme={null}
  <script src="f.js"></script>
  <script src="sdk.iife.js"></script>
  <script>
    sleek.initializeSdk("YOUR_PUBLIC_API_KEY_HERE");

    const classification = await sleek.getSdk().classifyPage(); // Returns Promise<PageClassification>
  </script>
  ```

  ```typescript CJS / ESM theme={null}
  import { initializeSdk, getSdk } from "@sleek/sdk";

  initializeSdk("YOUR_PUBLIC_API_KEY_HERE");

  const classification = await getSdk().classifyPage(); // Returns Promise<PageClassification>
  ```
</CodeGroup>

## Available page classifications

The SDK can classify pages into the following categories:

* `cart` - A shopping cart page
* `checkout` - A checkout page
* `checkoutComplete` - A completed checkout page
* `collection` - A category/collection page listing products
* `customersAccount` - A customer account page
* `customersAuthentication` - A login or registration page
* `customersOrders` - A customer orders history page
* `home` - A website's homepage
* `product` - A product detail page
* `search` - A search results page
* `other` - An e-commerce page that doesn't fit other categories
* `nonShopping` - A page that is not shopping related

**What's next:**

Now that you have enabled page classification, you can check out the TypeDoc for specific event types and methods on the SDK.

<Card title="View TypeDoc" icon="terminal" href="/js-sdk-reference/type-doc">
  Browse the reference TypeDoc for the SDK.
</Card>
