Advanced data collection
Page views
Transform values before they are saved to the backend in a view
To modify parameters just before a view is saved to the backend, define a transformViewParameters function. It runs automatically as the last step, and any changes you make are included in what gets saved. The example below logs the current parameters to the console.
function transformViewParameters(sendObject) {
console.log(sendObject);
// Here you can modify parameters before a view is saved to backend
}
window.__rekai.transformViewParameters = transformViewParameters;Save a page view with JavaScript
To save a page view using only JavaScript, run:
window.__rekai.sendView();Track visited pages
Save if a visitor has previously visited a page
It can be valuable to let the model know whether a visitor has previously visited a specific page, for example, whether someone on the home page already visited a sign-up form two weeks earlier, or whether a visitor has shown interest in "press" content before.
Rek.ai doesn't track this automatically, so it's a function you add yourself. The script below uses local storage to keep track of it: you list the URLs to watch for, each linked to a feature number (1–20).
var pathsToSaveAsFeature = [
{
f: 1,
paths: ['/press.html']
}
];In the example above, feature 1 is set to the value 1 for 30 days whenever the visitor visits a URL containing /press.html.
Save a page to visited pages via JavaScript
To save the current page to the visitor's list of visited pages:
window.__rekai.eventAddToSessionPath(window.__rekai.customer);Track clicks on external links
Links in HTML, for example, external applications
Wrap the links in a div with the class rek-link-listener:
<div class="rek-link-listener">
<a href="www.external.se">App 1</a>
<a href="www.site2.se">App 2</a>
</div>You can also add the class rek-link-listener directly to a link instead of wrapping it.
If links are added by JavaScript after the page loads, initiate link detection separately:
<script>
function rekPredictionDone() {
window.__rekai.addListenersToLinks();
}
</script>Add data to the link
To attach a feature to all clicks on a set of links, add data-featuref20="1" to the same div. You can also use these data attributes to send extra information to the backend, which is then returned with any resulting prediction:
data-rek-titledata-rek-imagedata-rek-descriptiondata-rek-urldata-rek-datedata-rek-pubdatedata-rek-pagetype
<a href="https://www.external.se/tjänst" data-rek-title="My Service">Service</a>If JavaScript is used to open external links
To register a page view before an event opens the link (for example, an external link opened programmatically), reuse the same function Rek.ai uses internally:
$svjq('#alink').on('click', function() {
window.__rekai.addTheEventToLink($svjq(this)[0]);
});If only a project with a certain id should save the click
This is useful when a site loads two or more rek.js files but only wants certain pages saved for certain projects:
<script type="text/javascript">
window.rek_viewclickprojectid = '10011001';
// If you want to save to many projects
// window.rek_viewclickprojectid = '10011001,10011002';
</script>Intranet and internal traffic
Intranet
If Rek.ai is running on an intranet, add the following to your 404 page so Rek.ai can detect when pages stop working:
<script>
window.__rekai = window.__rekai || {};
window.__rekai.errorpage = true;
</script>Block internal users from being tracked
Rek.ai doesn't process IP addresses on our servers, so we can't filter page views out of the AI model based on IP — something you'd typically want to do to keep employee page views out of the model. Instead, build a simple server-side check: if the visitor's IP matches your internal range, output a setting that blocks the page view.
[SERVER SIDE CHECK IF USER IP IS INTERNAL]
<script>
window.rek_blocksaveview = true;
</script>
[END]Block usage of beacons
Beacons send events to the backend. To block them, add this to the page:
<script>
window.__rekai = window.__rekai || {};
window.__rekai.blockSendBeacon = true;
</script>Cookies and consent
Do Rek.ai set cookies?
This section has moved. You'll find it under Cookies and consent.
Limit what data is saved in local and session storage
This section has moved. You'll find it under Cookies and consent.
Do we need consent to save data in local and session storage?
This section has moved. You'll find it under Cookies and consent.
Block usage of local storage and session storage
This section has moved. You'll find it under Cookies and consent.
Does Rek.ai work without local and session storage?
This section has moved. You'll find it under Cookies and consent.
Cookiebot
This section has moved. You'll find it under Cookies and consent.
Descriptions for consent tools
This section has moved. You'll find it under Cookies and consent.
Blocking and cleanup
Cleanup of data saved in session and local storage
This section has moved. You'll find it under Cookies and consent.