Implement Category pages

Nosto provides functionality to retrieve all products from specific category. This is useful when you want to implement category merchandising using the same search API.

API Requests

Using category ID

By providing categoryId parameter API will return all products associated with that category.

Query

query {
  search(
    accountId: "YOUR_ACCOUNT_ID"
    products: {
      categoryId: "123456789"
    }
  ) {
    products {
      hits {
        productId
        name
      }
      total
      size
    }
  }
}

Using category path

Search rules targeting specific categories are not supported when using categoryPath parameter, they supported only for categoryId parameter

By providing categoryPath parameter API will return all products associated with that category. This parameter is the same as categories product field.

Query

query {
  search(
    accountId: "YOUR_ACCOUNT_ID"
    products: {
      categoryPath: "T-Shirts"
    }
  ) {
    products {
      hits {
        productId
        name
      }
      total
      size
    }
  }
}

Using custom filters

Search rules targeting categories are not supported when using custom filters, they supported only for categoryId parameter

In rare cases categoryId or categoryPath is not enough. In these cases custom filters can be used to build any query for category & landing pages.

Query

query {
  search(
    accountId: "YOUR_ACCOUNT_ID"
    products: {
      preFilter: [
        {
          field: "productId",
          value: [
            "2276",
            "2274"
          ]
        }
      ],
    }
  ) {
    products {
      hits {
        productId
        name
      }
      total
      size
    }
  }
}

Other features & implementation

The category page shares a lot of similarities with the search page, so please refer to the search page documentation:

pageImplement Search results page

Analytics

Nosto Analytics

To analyze user behavior you need to implement tracking. This can be achieved using our JavaScript library. You need to implement the following methods with type = category:

Last updated