Recco.js
Recco.js is a self-hosted JavaScript library which can be used to rapidly build an interactive, single-page-application user interface around the Luigi’s Box Recommender API.
You can integrate Luigi’s Box Recommender by including the Recco.js script, setting configuration parameters and providing custom templates to customize the visual appearance.
Integration
Section titled “Integration”By following this guide you will configure your site to use Recco.js to make requests on your behalf to Luigi’s Box Recommender API and display these recommendations back to your users.
Prepare page for recommendations
Section titled “Prepare page for recommendations”Pick a page from your site that you would like to enrich with Luigi’s Box Recommender — product pages, shopping carts or even home pages work best. Create an empty placeholder element where Recco.js will render recommender UI into.
<div id="recommender-ui"> <!-- Empty placeholder for recommender UI --></div>Set up Recco.js
Section titled “Set up Recco.js”Include the script and set configuration parameters:
<script src="https://cdn.luigisbox.com/recco.js"></script><script> Luigis.Recommend({ TrackerId: '2291-22343', Theme: 'luigis', Size: 5, Name: 'basket_detail', Type: 'basket_recommender' }, '#recommender-ui')</script>Please note that:
- You must define your templates before you initialize Recco.js script. Templates are looked up when Recco.js first initializes.
- You must initialize the recommender by calling
Luigis.Recommend. The initialization function takes 2 arguments: configuration object and CSS selector for the placeholder element. - You must define the initialization script in the HTML after the placeholder element.
Without defining custom templates, you will get a very basic and unstyled recommender UI. You will most likely want to define custom templates where you can reuse your existing styles.
Content security policy
Section titled “Content security policy”If your website is using Content Security Policy, you need to add following rules to allow Luigi’s Box Recco.js to work.
| CSP directive | Value |
|---|---|
script-src | https://cdn.luigisbox.com |
connect-src | https://live.luigisbox.com |
style-src | https://cdn.luigisbox.com |
Prevent products from being recommended via annotations
Section titled “Prevent products from being recommended via annotations”You can prevent specific products from being recommended by adding a data-luigis-no-recommend annotation to their HTML elements. This is useful when you want to exclude certain products (e.g., the currently viewed product) from the recommendation results without modifying the API request.
<div data-luigis-no-recommend="PRODUCT_URL_OR_ID"> <!-- This product will be excluded from recommendations --></div>Was this page helpful?
Thanks.