Skip to main content
Available from @depict-ai/react-ui 4.10.33, @depict-ai/js-ui 4.10.30 and @depict-ai/dpc 2.6.26. Earlier versions don’t have the api option and always read the v3 endpoints.
By default the Depict UI SDK reads the v3 endpoints. With the option api: "v4", it reads search, listing pages, search suggestions and recommendations from the Platform API at https://api.depict.ai/v4/{merchant}, and sends tracking events to POST /v4/{merchant}/events. The option is opt-in, and v3 stays the default, so nothing changes until you set it. “V4” here is the API version. It is separate from the SDK’s own major version, which is also 4.

Switch it on

React

Set api="v4" on DepictProvider. Search, listing pages, suggestions and useFetchRecommendations all follow it.
DepictProvider creates its API client once, on its first render, so set api from the start rather than changing it later.

JavaScript

Pass api: "v4" to each provider, and to every fetchDepictRecommendations call. Recommendations take their own option, since they don’t go through a provider.
api takes "v3" (the default) or "v4".

Tracking

With api: "v4", the events the V4 contract can carry go to POST /v4/{merchant}/events: card impressions and clicks, add-to-carts, product page views and purchases. Events V4 has no place for stay on /create-events, so switching loses no data. You call DPC and dpq exactly as before.
  • React: @depict-ai/react-ui sets up DPC for you. A DepictProvider with api="v4" switches its events too. There is nothing else to set.
  • JavaScript: creating a provider with api: "v4" switches the events of the DPC you import from @depict-ai/js-ui. Also set the Performance Client’s api option, so the setting holds on pages without a provider, such as a page that only shows recommendations:
  • DPC from the CDN has its own copy of the tracking code, which a provider doesn’t reach. Set api: "v4" on it.
Set market on DPC: V4 events and purchases need it. Use the same setting on every page of the store, so each action is sent to one place.

What changes

  • Requests: keyless GETs to /v4/{merchant}/browse, /suggest, /listings and /recommendations. Your market and locale are sent as they are, with a locale such as en_GB sent as en-GB. Check them against /v4/{merchant}/context.
  • No session or metadata on content requests: sessionId and metaData aren’t sent to V4. Events still carry the session id.
  • Custom headers aren’t sent: fetchDepictRecommendations ignores headers on V4, and logs a warning.
  • Recommendation inputs: each request sends only the inputs its type reads, from recommendation_types in /context. productId becomes the anchor, and productIds the cart on a surface that reads one. The SDK caches /context for 15 minutes, so a newly set up surface can take up to 15 minutes to reach a browser.
  • Recently viewed products: V4 keeps no shopper session, so the SDK keeps a short history in the browser’s localStorage: up to 20 product ids with their view times, at most 30 days old. It sends the history only to surfaces that read recently viewed products.
  • Result counts: when V4 can’t count every match, the count is the number of products loaded so far.
  • Stale filter links: a filter in a link that the store no longer has is left out, and the page loads with the other filters instead of showing no results.
  • Discount filters: a discount filter means “this discount or more”, as on v3.

What stays the same

  • Your productCard, display transformers, layout and styling. The SDK maps each V4 response to the display shape it reads on v3, so your code gets the same fields.
  • The UI: the search modal, search page, listing pages, filters, sorting, pagination and URL state.
  • The DPC and dpq calls you make for product pages, add-to-carts and purchases.
  • Looks and shop the look, which stay on v3.

Test it

The SDK has no URL switch. To try V4 on your own storefront before you switch everyone, set api from your own flag, for example a query parameter:
Pass that value as api to your providers, recommendation calls and DPC. Read it once on page load. The Depict demo store at demo.depict.ai reads ?depict_api=v4 this way and shows a notice while it’s on, for example https://demo.depict.ai/MERCHANT_ID/MARKET/en_GB/?depict_api=v4. Check these while you test:
  • Search, suggestions, a listing with filters and sorting, and paging to the last page.
  • Each recommendation surface you use. A type V4 doesn’t serve for your store returns no products.
  • In the browser’s network tab, events go to /v4/MERCHANT_ID/events, and each answer has "rejected": 0. Confirm them in the portal’s Tracking status tab.

Known gaps

  • Looks and shop the look stay on v3.
  • Pinned products on the empty search page aren’t shown on V4 yet. A fix is on its way.
  • Display fields your display settings list, such as brand, aren’t on V4 cards yet. If your product card shows one, check it before you switch.
  • Hover images: a variant with its own image gets only that image, so on stores whose variants carry their own images, such as native Shopify stores, cards show no hover image.
  • Listing image choices, the main and hover image a listing sets for its products, aren’t applied on V4 listing pages.
  • Paging on some searches: a search can return the same product on two pages at some page sizes. The SDK shows it once, so the shopper sees one product fewer.
  • Recommendation surfaces: not every store’s configured surfaces are served on V4 yet. Those stores get similar only. Check recommendation_types in /context, or ask your Depict contact.
  • Recently viewed products fill only from product-page recommendation calls, in that browser.
Search results, listing headers and the rest of V4’s behavior are described in Endpoints.