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 field | Value sent |
|---|---|
product | The current product ID, a list of product IDs on a cart page, or null when the page has no product context. |
category | The current category ID, or null when the page is not a category page. |
page | The current template name when the page is neither a product nor category page; otherwise null. |
Use product context on cart pages
Pass the product IDs in the cart as a list, even if the cart contains just a single element:
<script>
Clerk('context', {
product: [123, 456]
});
</script>Updated 5 days ago
