Context

Tell Clerk.js which product, category, or page a visitor is currently viewing.

Use Clerk('context', ...) to tell Clerk.js which product, category, or page the visitor is currently viewing. This can be used to personalise recommendations, update the empty state in Omnisearch, allow Chat to understand what the visitor is currently seeing, and more.

Add the following snippet to your page template after Clerk.js has loaded. It passes the current product ID, category ID, or template name to Clerk.js and uses null when that context does not apply.

<script>
  Clerk('context', {
    product: 123,
    category: 456,
    page: 789
  });
</script>
Context fieldValue sent
productThe current product ID, or null when the page is not a product page.
categoryThe current category ID, or null when the page is not a category page.
pageThe current template name when the page is neither a product nor category page; otherwise null.