Custom features
rek.ai has 32 custom features.
Nr 1 to 20 is a float that has a value that goes from -1 to 1. These have the names f1 -> f20
Features 21 and 22, on the other hand, are a string.
There is also 10 custom features that can be strings. These are named: csf1 to csf10.
All custom features that are not used get the value 0 or "".
You sets the value of a custom feature by adding it to the code of the page.
For example, if you want to use a feature to store whether a user is logged in as either Customer or Supplier, you can use two features for this:
Circumstance | Javascript-rad |
---|---|
Not logged in | window.rek_customfeature['f1'] = 0; |
Logged in customer | window.rek_customfeature['f1'] = -1; |
Logged in supplier | wndow.rek_customfeature['f1'] = 1; |
Several options exist for how a custom feature can be sent to the system:
Save in the window object
Custom features are saved by adding an object to window. This fits well when the feature does not need to be saved between page views, but applies "globally". As if you are logged in, for example.
<script>
window.rek_customfeature = [];
// Check if user is a logged in supplier
window.rek_customfeature['f1'] = 1;
</script>
Save in session variable
You can also save features in a session variable. For this to work, the project time to which the feature belongs is used.
The Sessions variable must follow one of these two naming standards:
rek + featurenamn
Example for setting feature f14 to 1 for project 10021005:
sessionStorage.setItem('rekf14', 1);
With variable:
var key = 'rek' + 'f1';
sessionStorage.setItem(key,'1');
Save to localstorage
You can also save features in a local storage. It can be done both with and without project time:
Example for setting feature f14 to 1 for project 10021005:
localStorage.setItem('rekf14', 1);
Example for setting feature f14 to 1 for project 10021005:
localStorage.setItem('rek10021005f14', 1);
Save in a cookie
If the project allows the use of cookies, you can easily save a feature in a cookie that is then automatically used when the visitor returns to the website. The handling of the cookie name is the same as for session above.
<script>
var iHaveBeenLoggedInBefore =1;
function setRectCookie(name,value,days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days*24*60*60*1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + (value || "") + expires + "; path=/";
}
// Set feature 1 to value for 30 days
setRekCookie('rekf1', iHaveBeenLoggedInBefore, 30);
</script>
Feature 21 and 22 which can be a string
In the same way that you can store feature 1 to 20, you can store feature 21. The difference is that f21 is a string that will be handled differently by the AI model.
You don't need to encode the string. It is done automatically by the javascript.
For example, f21 can be used for:
- Which department a user on the intranet works in
- Settings a logged in user made
- Which football team is currently visiting the municipality
- The length of an event. Ex full day or 1 hour.
Example for setting feature f21 which can be a string to the location an employee works at:
localStorage.setItem('rekf21', 'the word');
Examples of using "labels" to support the recommendations
By assigning labels to pages, they can be more easily "connected". Perhaps your website already has labels you can send to us. You can then save these in feature 22.
A simple example of how this can be done in Sitevision is:
#set ($utils = $request.getAttribute('sitevision.utils'))
#set ($pu = $utils.propertyUtil)
#set ($currentPage = $utils.portletContextUtil.currentPage)
#set ($labels = $pu.getString($currentPage, 'labels', ''))
#if($labels != '')
<script>
window.rek_customfeature = [];
// Add labels to feature 22
window.rek_customfeature['f22'] = '$labels';
</script>
#end
If the project wants to use Custom String Features
These are handled in the same way as Custom Features but have the names csf1 to csf10 and are strings instead of floats like Custom Features. All values are encoded before being sent to the backend by rek.ai. They can therefore be stored in the following way:
sessionStorage.setItem('rekcsf1', 'Department of Finance');
sessionStorage.setItem('rek10311057csf2', 'Chef');
localStorage.setItem('rekcsf3', 'Test 3');
localStorage.setItem('rek10311057csf4', 'Test 4');
setCookie('rekcsf5', 'Test 5', 30);
setCookie('rek10311057csf6', 'Test 6', 30);
window.rek_customfeature = [];
// Check if user is a logged in supplier
window.rek_customfeature['csf7'] = 'Test 7';
window.rek_customfeature['rek10311057csf8'] = 'Test 8';
window.rek_customfeature['rekcsf9'] = 'Test 9';
How do I see if my custom features are sent correctly?
By looking at the network traffic when a "view" is sent to our backend, you can see if your features are sent along.