Advanced data collection
Cookies and consent
Do Rek.ai set cookies?
No. Rek.ai never sets cookies. Instead, it uses local storage and session storage by default, so the browser can temporarily remember which pages were visited during a session. This is also why we never track individual visitors.
Limit what data is saved in local and session storage
As the owner of a project, you can prevent Rek.ai from saving anonymous data in local and session storage. To prevent data from being saved in any of these, insert the following code on all pages.
<script>
window.__rekai = window.__rekai || {};
// Block save to session storage
window.__rekai.blockSaveToSessionStorage = true;
// Block save to local storage
window.__rekai.blockSaveToLocalStorage = true;
</script>Do we need consent to save data in local and session storage?
Most of our clients consider storage in localStorage and sessionStorage to be "necessary" for providing a good user experience on their websites and Rek.ai is designed so that its functionality never depends on this type of storage in the first place.
User consent is not required for all types of storage in localStorage and sessionStorage. It is important to understand when consent might be necessary:
Necessary storage
Storage that is essential for a website's functionality (e.g., managing a user's session, settings, or shopping cart) is often considered "necessary" and may not require active consent under regulations like GDPR and the ePrivacy Directive.
Non-necessary storage
Storage used for other purposes — such as tracking, analytics, or advertising (especially when it involves collecting identifiable user information or impacting privacy) — typically requires explicit user consent.
Summary:
- Necessary functionality: consent is typically not required.
- Non-necessary storage, particularly for profiling and tracking: consent may be required.
That said, we fully respect different interpretations of this issue.
Block usage of local storage and session storage
To restrict storage usage on a consent basis, do the following:
- When embedding the Javascript on your pages, add
data-useconsent="true"to the script tag:
<script src="https://static.rekai.se/YOUR VERSION OF THE SCRIPT.js" data-useconsent="true" defer></script>- Set the global variable
window.__rekai.consentacceptedtofalseafter the script tag:
<script>
window.__rekai = window.__rekai || {};
window.__rekai.consentaccepted = false;
</script>With these two steps in place, nothing is saved to browser storage but visitors will still receive recommendations.
Cookiebot
If you use Cookiebot and want Rek.ai to hold off storing data in local and/or session storage until the visitor accepts "Statistic cookies," add data-useconsent="true" when loading the Javascript — the same attribute used above:
<script src="https://static.rekai.se/YOUR VERSION OF THE SCRIPT.js" data-useconsent="true" defer></script>Descriptions for consent tools
If you use a consent management tool, you'll typically need to describe each stored value. Here's copy you can use on your information page:
Your website uses the Rek.ai service to collect anonymous statistics in order to make page suggestions for our visitors. The anonymous statistics we have access to are time, pages visited, and information from the browser. Rek.ai is used in several places on the website, including displaying direct links, news or autocomplete suggestions.
And here's a reference list of everything Rek.ai stores, for filling in your consent tool:
Session storage:
| Name | Identifier | Description | Description SE | Retention |
|---|---|---|---|---|
| Pages in session | sp[projectid] | Pages visited in this session | Sidor som besöktes under denna session | Deleted after session is closed |
| Last page | last[projectid] | Last page visited in this session | Senast besökta sidan i denna session | Deleted after session is closed |
| Orgreferrer | rekOrgRef | Original referrer address for this session | Ursprunglig referensadress för denna session | Deleted after session is closed |
| Session time | sessionstarttime | Date object for when session began | Datumobjekt för när sessionen började | Deleted after session is closed |
| Tabs in session | rektabs | Array of "section pages" the user has visited in the current session | Lista med "sektionssidor" som användaren har besökt under den aktuella sessionen | Deleted after session is closed |
Local storage:
| Name | Identifier | Description | Description SE | Retention |
|---|---|---|---|---|
| Dates | vds[projectid] | Array of dates the browser visited the site | Lista med datum som webbläsaren besökte webbplatsen | Saved in local storage over time |
Consent tools:
| Name | Identifier | Description | Description SE | Retention |
|---|---|---|---|---|
| A setting | rekai_consent_accepted | A setting for accepted consent via a consent tool | Om ni använder en consent-verktyg |
Here's an example of what a consent tool's view can look like:
Blocking and cleanup
Cleanup of data saved in session and local storage
To delete everything Rek.ai has saved to session and local storage, run:
window.__rekai.removeLocalAndSessionStorage();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>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, trigger it by running:
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="http://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]