Advanced implementing
Connect rek.ai events to custom implementation
If you want to connect rek.ai events to your own implementation, you need to do som extra work.
The most important event is the "view" event that is triggered when a question is opened by a visitor. It is this event that the AI mopdel uses to learn which questions are popular and should be recommended more often.
For this to work every question needs to know what question ID it has.
In our default html implementation the question ID is stored in a data-rek-entityid attribute on the button element.
Then when a question is opened we trigger the rek.ai event like this:
// Send view "click" for this question id
var myEntityid = accordionButton.dataset['rekEntityid'] || '';
if(myEntityid != '') {
if(window.__rekai.allClickedFAQs.indexOf(myEntityid) == -1) {
window.__rekai.allClickedFAQs.push(myEntityid);
// Now update paramters and send view
window.__rekai.entitytype = 'rekai-faq';
window.__rekai.entityid = myEntityid;
window.__rekai.sendView();
//console.log('send view: ' + myEntityid);
}
}