$p("register")

$p("register"): (Object) -> Boolean

📘

Technical documentation

This page includes technical documentation around the register function, used as part of the code to render LiftIgniter recommendations. For broader context around rendering, see our documentation on Rendering Widgets.

Register function prepares recommendation query to LiftIgniter's model server. You can set multiple registers before running $p("fetch"). Every time the register function is invoked, then our SDK will queue that request, and execute it once $p("fetch") is invoked.

Register calls are differentiated by the opts object passed into options. So number of model queries being made will be equal to number of registers with different kind of opts parameter.

The output of the register call is true if the register was successful, and false if not.

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

// Requests for articles that's marked as news.
$p("register",{
	max:5,
  widget: "news_rec",
  opts: {channel: "news"},
  callback: function(resp){
    console.log(resp)
  }
})

// Calling fetch once executes both registers.
// Results in two different kinds of recommendations.
$p("fetch")