Any field in your inventory can be used as the basis for a filter. Some common examples are:

  • type - article, video, gallery, review, product, etc
  • category - sweaters, pants, jackets, hats, etc
  • keywords - river, ecology, water, frogs


Filters can be based on either strings (single-value fields) or arrays (the field might have multiple values in it, like keywords). These can be controlled at the widget level by including the field name as a parameter in the request for recommendations, which allows you to flexibly turn filters off or on, or dynamically insert the value to use in the filter. We can also apply filters at a global account level if you'd like it to always apply to all widgets.


Setting Up a New Filter

  1. Contact Support and let us know which field in your inventory you'd like to use as a filter
  2. LiftIgniter will activate a filter rule for that field within a few days of receiving the request
  3. Once active, you can include the field name and value as part of the widget request.

If the field you are using is an array field we can set up the rule to accept ANY matching values, or ALL matching values. Allowing ANY values to be matched gives a wider pool of items for our models to choose from, and also minimizes the risk of accidentally requesting a combination that has very few matches. In other words, if you only have two articles in your inventory with all of the values requested, those are the only two items we'll be able to recommend when using the ALL logic!


Matching ANY:

Request keywords : ["river", "water", "frogs"]

Recommended items may have keyword sets like ["beach", "water", "sunset"] or ["animals", "lizards", "frogs"]


Matching ALL:

Request keywords : ["river", "water", "frogs"]

Recommended items must have all 3 of the above keywords, and can also have additional keywords.


Using a Filter (JS)

If you are requesting recommendations via our Javascript integration, you'll include the rule in an "opts" parameter in the $p("register") function. That will look something like:


$p('register', {
            max: 4,
            widget: 'my-widget-name',
            opts: {"type": "video"},
            callback: function(resp) {
                // You might wish to wrap the code in this callback inside jQuery, to handle load order issues
                //render the recommendations
                rendering_callback(resp);
                // track the recommendation area as the variant slice with a custom source name.
                trackAlgo('filtered');

In this example, only items that have "type" : "video" in their metadata will be returned.


If you want to include multiple values, simply format the values as a JSON array:

$p('register', {
            max: 4,
            widget: 'my-widget-name',
            opts: {"keywords": ["river", "water", "frogs"]},
            callback: function(resp) {
                // You might wish to wrap the code in this callback inside jQuery, to handle load order issues
                //render the recommendations
                rendering_callback(resp);
                // track the recommendation area as the variant slice with a custom source name.
                trackAlgo('filtered');


Using a Filter (API)

Filters can be activated in an API integration by including them in the JSON body of the request to the /model endpoint. Here is a simplified API request including a filter for "category" with an array of requested values.


curl -X POST \
  https://query.petametrics.com/v2/model \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/json' \
  -d '{
  "apiKey" : "yourAPIkeyhere",
  "url" : "http://www.domain.com/current-url",
  "category" : ["politics", "economy"],
  "userId" : "xxxxxxx"
}'


Global filters

While most filters are applied at the widget level, we can also apply filters at the account level. This is most common for very broad filters, such as only allowing article and video items to be recommended, or non-Premium content, or items that are marked as in-stock. If you'd like a filter to be applied globally for your account, just let us know!