Development environment
If you want to test the functions and recommendations from rek.ai in a development environment before going live, you can do it in two diffrerent ways. Ether by adding the development environment to Allowed domains in the Dashboard or by sending your project id and secret key with the request.
Note: In some cases, your development environment has its own project and in other cases it's the same project as in production so be careful of which secret key, project id and script you are using in the development environment.
Activate recommendations in a development environment
Development environment with Allowed domains
- In the Dashboard, go to Allowed domains and add your test environments URL.
- Add your projects static script to the test environment. You can find the script in the Dashboard Overview or General settings.
- Add the cookie below to prevent page views from being saved in the test environment, add this to all pages.
<script>
document.cookie = 'rekblock=1; max-age=60; SameSite=None; Secure';
</script>- Start testing your recommendations:
<div class="rek-prediction" data-subtree="/news/" data-nrofhits="5"></div>Development environment with Project-ID and Secret key
If the development environment is, for example, localhost- this is the only way to test since localhost cannot be added to Allowed domains in the Dashboard.
- Add your projects static script to the test environment. You can find the script in the Dashboard Overview or General settings.
- Add the cookie below to prevent page views from being saved in the test environment, add this to all pages.
<script>
document.cookie = 'rekblock=1; max-age=60; SameSite=None; Secure';
</script>- To get recommendations you need the Project-ID and Secret key, find them by logging into the Dashboard (opens in a new tab):
- Add these as data parameters (srek is secretkey) and start testing your recommendations:
<div class="rek-prediction" data-projectid="ENTER PROJECT ID" data-srek="ENTER SECRET" data-subtree="/news/" data-nrofhits="5"></div>If you are using Sitevision, you add the Project-ID and Secret key in the Advanced field of the Sitevision module as shown below.
Activate search in a development environment
With Sitevision autocomplete
<script src="https://static.rekai.se/files/sv-autocomplete.min.js"></script>
<script>
svDocReady(function() {
$svjq(".sv-searchform-portlet input[name='query']").rekAutoComplete({ // ID for the search input field
sendToTarget: true,
params: {
projectid: 111111,
srek: 'YOUR SECRET'
}
});
});
</script>With generic rek.ai autocomplete
<script src="https://static.rekai.se/addon/v3/rekai_autocomplete.min.js"></script>
<script>
__rekai.ready(function() {
var rekAutocomplete = rekai_autocomplete('#search-input', { // ID for the search input field
params: {
projectid: 111111,
srek: 'YOUR SECRET'
}
});
});
</script>Test with mock data
By adding a parameter, each prediction can return mock data which helps when developing advanced_mockdata.