Analytics & Reports

Hide Previously Purchased Items

As part of the Recommendations API data, if you beacon order data, you are able to get a list of what a given visitor has already purchased.

Business Goal: I want to make it easier for my customers to find new to them products - so that if they are shopping for similar items, they can easily hide items that they have already bought.

Use cases

The kinds of industries where this kind of experience is particularly applicable is when we have series of items, such as:

  • books by an author or songs by an artist - we can hide previously bought items and see just the ones not bought yet
  • courses from a given series - so that customers don’t accidentally re-purchase items they already have

Conversely, you can use the same logic to highlight previously purchased items. This can be useful in industries where shoppers return for the exact same item multiple times, such as:

  • Ink for a printer model, as only a specific kind can be re-bought
  • Personal care items that are regularly re-stocked, such as make-up
  • Household items, such as candles, that burn out

This can then be used in the search results as a toggle to Hide/Highlight previously purchased items: by using a filter of loginId and some front-end logic the results can be personally tailored to your visitors.

Sample Query

This query relies on 3 factors:

  1. The loginId. This must be loginId as that’s the only way to ensure we have the correct order data.

    The exact syntax to filter down to the session ID is: "matchExact":{"and":[{"visit":{"customerData":{"loginId":"<the user login ID>"}}}]}

  2. The event type of order

  3. The window of how far back we want to look (this can be day, week, or month) - this example uses month

Note that you need to set the target parameter to sku or productId, which you should choose considering whether you think your customers would be repurcharsing by SKU or product ID.

curl -H "Authorization: --clientKey--" \
    -XPOST "" \
    -d '{"type":"order", "target":"productId", "window":"month", matchExact":{"and":[{"visit":{"customerData":{"loginId":"<current login ID>"}}}]}}'

Sample Response

The response will be a list of productIds or skus, depending on what target was chosen.

  "serverTimestamp": "2017-10-31T19:38:02+00:00",
  "result": [
      "productId": "5042812634"
      "productId": "3600040797"
      "productId": "4000046410"
      "productId": "5042830412"
  "status": {
    "additionalInfo": null,
    "message": "OK",
    "code": 200

Excluding IDs via the Search API

If you are looking to exclude the items via the Search API, you can do so with a new query and using the exclude function of the refinements parameter to the Search API:

{ "refinements": [
  {"type": "Value", "navigationName": "productId", "value": "5042812634", "exclude": true },
  {"type": "Value", "navigationName": "productId", "value": "3600040797", "exclude": true },
  {"type": "Value", "navigationName": "productId", "value": "4000046410", "exclude": true },
  {"type": "Value", "navigationName": "productId", "value": "5042830412", "exclude": true }
  ] }

Highlight or Excluding Without a Query

If you want to do this without sending a new query, then you can do this by using front-end logic only. You will need to check against the items rendered on screen and hide or highlight them.

This type of operation is highly dependent on your front-end implementation - please reach out to your Customer Contact to request additional information on how this is done.