First review that category tagging on product detail pages (PDP) is solid and features the category or categories a product belongs to.
Link to general implementation guide (debug mode)
Secondly, if a product is attached to multiple categories the exclude/include rule might not work effectively (or at all) as in such a case products are either included from multiple categories or multiple categories are excluded.
Product Belongs To Multiple Categories
For example if you’ve set the recommendation to include products from the same category, but based on the implementation the product belongs to categories:
<div class="nosto_product" style="display:none">
<span class="category">/New In</span>
The algorithm will pull out and display alternatives across all listed categories. If the intended use case is to present alternatives from the same generic product category, in the example “/Womenswear/Clothing/Dresses”, the recommendation would display items also from New In category, which is probably undesirable.
Nosto debug-mode enabled. In the example, a product belongs to multiple different categories and category levels so by default cross-sellers would recommend products across New In and Womenswear.
Using Active Category Tag
As products often belong to multiple categories in the site’s navigation hierarchy, you might need to amend the implementation and apply nosto_category tagging also on product pages, which is prioritised over product’s own categories. The tagging essentially ties a product to only single category per time and ignores the others. Adding Nosto “category tagging” such as below
<div class="nosto_category" style="display:none">/Womenswear/Clothing/Dresses</div>
would in the example attach the product only to one generic product category under Womenswear and Clothing titled as “Dresses”. In this case, if the recommendation filters are set to display alternatives from the same category only other dresses are displayed while products belonging into “New In” are now excluded.
Nosto debug-mode enabled. In the example, the active subcategory is now “Dresses” which defines product’s active category and overwrites additional categories. Thus alternative products in cross-sellers would be: Other dresses while supplementary products would be: “Other items, but not dresses”
The nosto_category tagging value is dynamic and unlike product page tagging supports returning the value by scripting, which makes it easier to return a different value inside the tag in case a customer find the product using a different navigation path, in the example by browsing “New In” special category.
<div class="nosto_category" style="display:none">/New/In/Womenswear</div>
Nosto debug mode enabled: Notice the areas highlighted in red. The active category is now /New In/Womenswear because the customer used different category hierarchy to find the same product. Notice the difference in cross-sellers to previous screencapture (right frame).
On the contrary to previous, in this example the same recommendation will now display items from category “New In” even though the viewed product is the same.
To conclude, a present “nosto_category” tag on a product detail page allows you to attach a product dynamically to any category based on the use case. It often is or should be consistent with the breadcrumb trail.