Sitevision specific
How you can add page and user information on an intranet
By using the data fields available for users in the directory, we have the capability to enhance the AI model by integrating additional functionalities.
The process involves utilizing Velocity (or any other server side code) to retrieve the necessary values, followed by embedding these values within the JavaScript code. Should there be a requirement to incorporate additional strings, it is feasible to extend the range by including identifiers from 'rekcsf1' through to 'rekcsf10'.
<!-- This part sets custom features for recommendations -->
#set ($utils = $request.getAttribute('sitevision.utils'))
#set ($user = $utils.portletContextUtil.getCurrentUser())
#set ($pu = $utils.getPropertyUtil())
#set ($department = $pu.getString($user, 'department', ''))
#set ($title = $pu.getString($user, 'title', ''))
#set ($physicalDeliveryOfficeName = $pu.getString($user, 'physicalDeliveryOfficeName', ''))
<script>
// Feature CSF1 is a string, here you can save "avdelning"
localStorage.setItem('rekcsf1', '$department');
// Feature CSF2 is a string, here you can save "title"
localStorage.setItem('rekcsf2', '$title');
// Feature CSF3 is a string, here you can save "physicalDeliveryOfficeName"
localStorage.setItem('rekcsf3', '$physicalDeliveryOfficeName');
</script>
Also check out: Intranet tutorials
Iterate all user properties
In order to be able to add user parameters to your ai model on an intranet, you need to know which parameters exist on each user. In Sitevision, this can be listed with a script.
Create a page with a script module and enter the following in the Javascript window.
// Get utilities in the SiteVision Public API
var utils = request.getAttribute("sitevision.utils");
var propertyUtil = utils.getPropertyUtil();
var ctxUtil = utils.getPortletContextUtil();
// Get current user
var user = ctxUtil.getCurrentUser();
// HTML Output
out.println("<table style=\"border-collapse: collapse;\">");
out.println("<caption style=\"padding:10px;\">User Attributes</caption>");
out.println("<tbody>");
out.println("<tr><th style=\"padding:10px;\">Attribute</th><th style=\"padding:10px;\">Value</th></tr>");
// Iterate user properties
var allPropertiesIterator = user.getProperties();
while(allPropertiesIterator.hasNext())
{
out.println("<tr>");
try {
var property = allPropertiesIterator.nextProperty();
var pName = property.getName();
var pValue = propertyUtil.getString(user, pName, "null");
out.print("<td style=\"padding:10px;border:1px solid #cccccc;\"><b>" + pName + "</b></td>");
out.print("<td style=\"padding:10px;border:1px solid #cccccc;\">" + pValue + "</td>");
} catch (e) {
out.println("Exception occurred: "+ e);
}
out.println("</tr>");
}
out.println("</tbody>");
out.println("</table>");
var userType="";
try {
userType=propertyUtil.getString(user, "employeeType", "null");
} catch (e) {}
out.println("<h3>"+userType+"</h3>");
When you know what parameters that exists you can add them to custom features
Control whether a certain IP should not be saved as a page view
It may be that you want to avoid the employees' page views being included when saving page views.
You can do that by checking the IP in Velocity before running the script to save.
#set ($utils = $request.getAttribute('sitevision.utils'))
#set ($clientUtil = $utils.getClientUtil())
#set ($dontAddThisIP = '1.2.3.4')
#if ($clientUtil.getClientAddress() == $dontAddThisIP)
<script>
window.rek_blocksaveview = true;
</script>
#end
Use IP number as a custom feature
If you want to be able to distinguish an employee and thus give them better recommendations, you can easily use your IP as a custom feature.
This means that you set custom feature 1 to the number 1 if the current visitor has the same IP as all employees.
#set ($utils = $request.getAttribute('sitevision.utils'))
#set ($clientUtil = $utils.getClientUtil())
#set ($employeeIP = '1.2.3.4')
#if ($clientUtil.getClientAddress() == $employeeIP)
<script>
window.rek_customfeature = [];
// Custom feature 1 is for employee
window.rek_customfeature['f1'] = 1;
</script>
#end
How to use Cookie banner together with the rek.ai Sitevision module?
Info: Rek.ai does not use cookies unless you as a customer have made an active choice. Rek.ai uses local storage and session storage to save data.
Conditions:
You userek.ai modules from sitevision marketplace
You have installed the Cookie banner module from sitevision markeplace. (Read about how yougetting started with the Cookie banner module)
Step 1
Open the Cookies panel which you will find under Website Settings
step 2
Select "Add cookie" under the category "Analytical cookies"
Step 3
Fill in the form with the following information
- Name:rek.ai
- Identifier: rekai
- Description:Optional descriptive text
Step 4
Save & publish.
Now rek.ai will automatically wait to save information in localstorage and session storage until the user has approved cookies.
Proxy code for SiteVision
If you want to add a proxy that all your traffic passes through before it reaches our servers, it is completely possible. Contact us and we will send you more information on how to proceed.