JSON-LD Filter on metadata

JSON-LD Filter on metadata

The parameter ldjsonfilter (opens in a new tab) lets you filter recommendations based on values in your JSON-LD.

<div class="rek-prediction" data-ldjsonfilter.keywords="summer"></div>

Or if the prediction is made via Javascript:

options.params['ldjsonfilter.keywords'] = 'summer';

Complete example of adding and filtering on additionalType

To make a page filterable, add this to its ld+json object:

<script type="application/ld+json" data-rekai>
  {
    "@context": "https://schema.org",
    "@type": "Article",
    "additionalType": "Podcast"
  }
</script>

You can then filter on this value either in the HTML div:

<div class="rek-prediction" data-ldjsonfilter.additionalType="Podcast"></div>

Or via Javascript:

<script>
  $( document ).ready(function() {
    function printPredictions(data) {
      console.log(data);
    }
 
    var options = {
      params: {
        subtree: '/news/',
      }
    };
 
    // Filter on this keyword
    options.params['ldjsonfilter.additionalType'] = 'Podcast';
 
    window.__rekai.predict(options, printPredictions);
  });
</script>

Comma separate the filter

If you enter multiple values separated by a comma, the page is recommended if any one of them matches.

<div class="rek-prediction" data-ldjsonfilter.additionalType="Podcast,Movie"></div>

Reverse the filter with "!"

To filter out pages that match a keyword instead, prefix it with "!".

<div class="rek-prediction" data-ldjsonfilter.additionalType="!Movie"></div>

Use category to filter products or pages

If a website has many products divided into categories, you can filter using "category". Rek.ai reads "category" from your JSON-LD object, and lets you filter on that value using data-ldjsonfilter.category.

Categories are divided into subgroups the same way Google does it, by adding ">" to the string.

Example: "Food>Breakfast>Eggs"

You can filter on any of these levels to get all products within that category.

Example: data-ldjsonfilter.category="Food>Breakfast"