Library Reference
Configuration
10 min
specific configuration values used by klevu are kept as a snippet of code which looks something like the following var options = { url { search 'https //eucs3v2 ksearchnet com/cs/v2/search', landing '/search results', queryparam 'q' }, search { apikey 'klevu 123xxxxxxxxxxxxxx', searchboxselector 'input#klevu search', } analytics { apikey 'klevu 123xxxxxxxxxxxxxx' } }; klevu(options); settings settings available within options object 166,209,300,112 true unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type useful configuration setting examples the above configuration settings can be passed directly into the main klevu function as an object as shown below code example klevu({ search { minchars 2, placeholder "ready to search?", redirects { "my cool blue" "https //mywebsite com/my cool blue product", "hot" "https //mywebsite com/sale" } } }); useful local storage settings true 187,96 unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type code example // this code waits for klevu js to load first window klvready= window klvready|| \[]; window klvready push(function(){ // we will set the items per page one time using a variable var itemsperpage = 24; // now we can use the variable to set both the product and content tab // items per page localstorage setitem('klv limits productlist', itemsperpage); localstorage setitem('klv limits contentlist', itemsperpage); }); useful data protection settings klevu's template js library uses an opt in consent system that controls whether the library can or cannot send user activity data to klevu this does not stop klevu services like search and recommendations from working, but rather it can block any user activity data from being sent to kelvu this data is what can power personalized user experiences and the main algorythm that powers all of klevu in other words, when you opt in to using the consent system, each user can consent or not consent to sending this activity data you can use any mechanism you would like to ask and track this consent, but you can use the following settings to tell the library that a user has given or not given consent code example klevu({ dataprotection { useconsent true, // enable the consent system for all users consentstate false, // user specific setting to opt in or out } }); because the consent system is opt in, it is not required to use these settings if you do want to use the consent system, then make sure useconsent is always set to "true" and for each user, set their consentstate to "true" or "false" most customer that use the consent system will set useconsent to "true" and consentstate to "false" until the user has specifically given consent then you can set consentstate to "true" for that user useful session storage settings for key names that include \[apikey] you would replace this with your account's apikey value here's an example sessionstorage setitem(`klv view klevu 14728819608184175 productlist`, 'grid'); key name key value default description klv view \[apikey] productlist grid available values are "grid" and "list" klv view \[apikey] contentlist list available values are "grid" and "list" code example // this code waits for klevu js to load first window klvready= window klvready|| \[]; window klvready push(function(){ // run this function when search and/or category pages load klevu beforeactivation('landing,catnav', function(data ,scope){ // set session storage value using a useful function to dynamically // retrieve your apikey sessionstorage setitem(`klv view ${klevu pagemeta getapikey()} productlist`, 'list'); }, 'build'); });

