Advanced data collection

Advanced data collection

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>

Block usage of local storage and session storage

If you want to restrict usage of local storage and session storage, you can do this by doing the following settings:

  1. When embedding the javscript code to your pages, add the following parameter to the script tag: data-useconsent="true"
<script src="https://static.rekai.se/xxxxx.js" data-useconsent="true" defer></script>
  1. Set a global variable window.__rekai.consentaccepted to false after the script tag.
<script>
  window.__rekai = window.__rekai || {};
  window.__rekai.consentaccepted = false;
</script>

If you follow the above steps nothing will be saved in the browser storage, but the visitor will still be able to recieve recommendations.

Descriptions for consent tools

Should you use a tool to manage website visitors' consent for cookies, it is necessary to provide a description for each respective value. Here is a comprehensive list of descriptions that you may fill in when setting up such a system.

Session storage:

NameIdentifierDescriptionDescription SERetention
Pages in sessionsp[projectid]Pages visited in this sessionSidor som besöktes under denna sessionDeleted after session is closed
Last pagelast[projectid]Last page visited in this sessionSenast besökta sidan i denna sessionDeleted after session is closed
OrgreferrerrekOrgRefOriginal referrer address for this sessionUrsprunglig referensadress för denna sessionDeleted after session is closed
Session timesessionstarttimeDate object for when session beganDatumobjekt för när sessionen börjadeDeleted after session is closed
Tabs in sessionrektabsArray of “section pages” the user has visited in the current sessionLista med "sektionssidor" som användaren har besökt under den aktuella sessionenDeleted after session is closed

Local storage:

NameIdentifierDescriptionDescription SERetention
Datesvds[projectid]Array of dates the browser visited the siteLista med datum som webbläsaren besökte webbplatsenSaved in local storage over time

Here is an example of a view from a consent tool can look.

Consent

Transform values ​​before they are saved to the backend in a view

If you want to change parameters in the last step before saving to the backend. Add the following to a Javascript on the web page and the data will be printed to the console. All these parameters can be overwritten or changed before a view is saved.

function transformViewParameters(sendObject) {
  console.log(sendObject);
  // Here you can modify parameters before a view is saved to backend
}
 
window.__rekai.transformViewParameters = transformViewParameters;

Save if a visitor has previously visited a page

There can be great benefits in letting the model know if a visitor has previously visited a page on the website.

For example, you may want the home page to know if the visitor visited a form to sign up as a customer two weeks earlier. Or if a visitor visited the page for "press" so the model can gain knowledge if this is a topic the visitor has an interest in.

Since rek.ai does not automatically use any type of tracking, this is a function you can easily add yourself.

The script below uses local storage to keep track of this.

In this object, you can enter the URLs to be saved if the visitor visits.

A feature number is linked to the URL (so one of the numeric 1-20).

var pathsToSaveAsFeature = [
  {
    f: 1,
    paths: ['/press.html']
  }
];

So in the example above, feature 1 will be set to the value 1 for 30 days if the visitor visits a URL that contains "/press.html".

Save a page to visited pages via Javascript

To save the current page you are on to the list of visited pages.

window.__rekai.eventAddToSessionPath(window.__rekai.customer);

Save clicks on external links

Links in HTML, for example, external applications

Create a div that wraps the links. Give that div 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>

It is also possible to give the link itself the class "rek-link-listener".

If links are added by Javascript after the page is loaded, the function for detecting links needs to be initiated separately.

<script>
  function rekPredictionDone() {
     window.__rekai.addListenersToLinks();
  }
</script>

Add data to the link

If all clicks on these links are to have their feature, you can add data-featuref20="1" in the same div.

It is also possible to use data parameters to send information to the backend which is then sent back in the event of a prediction:

  • data-rek-title
  • data-rek-image
  • data-rek-description
  • data-rek-url
  • data-rek-date
  • data-rek-pubdate
  • data-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

It is possible to use the same function that rek.ai uses to register a page view before an event opens the link (for example if it is an external link).

$svjq('#alink').on('click', function() {
  window.__rekai.addTheEventToLink($svjq(this)[0]);
});

If only a project with a certain id should save the click

This may be necessary when a site has two or more rek.js files loaded, but you want certain pages to be 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>

Save a page view with Javascript

If you want to save a pageview only using Javascript, you can trigger it by running the function.

window.__rekai.sendView();

Intranet

On intranet: Add information about which is the 404 page In order for rek.ai to be able to determine when pages on the intranet stop working, it is good if you add the following code to your 404 page:

<script>
  window.__rekai = window.__rekai || {};
  window.__rekai.errorpage = true;
</script>