The register function defines the recommendation queries that will be sent to LiftIgniter's model server. You can register multiple widgets before running $p("fetch"). Every time the register function is invoked, our SDK will queue that request, and execute it once $p("fetch") is invoked. Each widget registered will count as a single API call when fetched.


Register calls are differentiated by the "opts" object passed into the function arguments and the number of items requested for each widget area.


Best Practices

Request only the number of items that you need to populate the recommendation area. Especially if you are using multiple widgets on a page, requesting extra items for each widget would result in high-ranking recommendations not being displayed, and can potentially lower CTR performance.


Use LiftIgniter's filtering and rules system to prevent unwanted items from appearing in recommendations. We have powerful tools available and can significantly customize your account to ensure only the right kinds of items and topics are displayed to your users. Filtering items out after our recommendations have been returned can result in having insufficient items to populate the widget area.


Options Available

Each option is turned into a query parameter in the request to our servers. You can include any number of options, or invoke any of the filters that we set up for your account on a per-query basis if desired.


Standard Options - Automatically available in your account

  • maxAgeInSeconds - limit recommendations to only those published since a specific amount of time ago
  • excludeItems - filter out specific URLs


Custom Rules - Please contact Support to speak with us about the filter logic needed. 

We'll create the filters and provide instructions on how to trigger them. In general, the option will be the name of the field you want to filter by. A common example would be a category filter, that allows only items in the categories you specify.


Handling Timeout Behavior

Default Timeout Behavior 

You may want to configure LiftIgniter's default backup recommendation logic to be turned on for cases when requests time out. The default backup recommendations do not adhere to rules defined for a particular integration. Learn more on how to implement this here (see the "SDK Options" table and the row for the "enableBackup" config option).


Custom Timeout Behavior

If you would like to disable default backup recommendations and custom-define your own timeout logic, you can do so using the "onTimeout" function (defined in the third example below).

You will first have to reconfigure the default timeout behavior using the "enableBackup: false" config described here (see the "SDK Options" table and the row for the "enableBackup" config option).

Note that the "onTimeout" function does not accept any arguments. Simply define your rendering and tracking logic in the function body. Please contact Support if you have questions on implementing "onTimeout".


Code Snippets


// Requests articles that were published within last 24 hours (86400 seconds)
$p("register", {
  max: 5,
  widget: "new_news",
  opts: {maxAgeInSeconds: 86400},
  callback: function(resp) {
    console.log(resp)
  }
})

// Requests articles that are marked as news
$p("register", {
  max: 5,
  widget: "news_rec",
  opts: {category: "news"},
  callback: function(resp) {
    // Note: You will replace the below with the actual rendering and tracking logic
    // when using the recommendations in production
    console.log(resp)
  }
})

// "onTimeout" specifies how to handle recommendations in case of timeouts,
// when default backup recommendations have been disabled
$p("register", {
  max: 5,
  widget: "news_rec",
  opts: {category: "news"},
  callback: function(resp) {
    // Note: You will replace the below with the actual rendering and tracking logic
    // when using the recommendations in production
    console.log(resp)
  },
  onTimeout: function(){
    // Note: You will replace the below with the actual rendering and tracking logic
    // when recommendations fail to load in production
    console.log("Handle failure to load LiftIgniter recommendations")
  }
})