This document will guide you through the aspects of integrating Klevu Recommendations with other platforms. Once you are finished with this guide, please refer to the generic instructions for other aspects like creating a banner and adding it to your store, editing a banner, etc.
Integration Steps
Below we have highlighted the generic skeleton which will work on any platform. Please ensure these elements are included within the of every page of your website where you wish to show Klevu Recommendation banners.
<script type="text/javascript">
// use your own logic to determine the current page type
var page_type = 'REPLACE ME!';
if (page_type == 'category') {
var klevu_page_meta = {
'pageType': "category",
'categoryName': 'REPLACE ME!',
'categoryUrl': 'REPLACE ME!'
};
}
if (page_type == 'product') {
var klevu_page_meta = {
"pageType": "pdp",
"itemName": "REPLACE ME!",
"itemUrl": "REPLACE ME!",
"itemId": "REPLACE ME!",
"itemGroupId": "REPLACE ME!",
"itemSalePrice": "REPLACE ME!",
"itemCurrency": "REPLACE ME!"
};
}
if (page_type == 'cart') {
var cartRecords = [];
cartRecords.push({
'itemId': 'REPLACE ME!',
'itemGroupId': 'REPLACE ME!'
});
var klevu_page_meta = {
'pageType': "cart",
'cartRecords': cartRecords
};
}
</script>
<script src="https://js.klevu.com/core/v2/klevu.js"></script>
<script src="https://js.klevu.com/recs/v2/klevu-recs.js"></script>
<script type="text/javascript">
klevu.interactive(function () {
var options = {
powerUp: {
recsModule: true
},
recs: {
apiKey: 'klevu-12345'
},
analytics: {
apiKey: 'klevu-12345'
}
};
klevu(options);
});
</script>Please replace klevu-12345 with your own Klevu JS Api Key. Also, for any customers already using Klevu JavaScript Library (aka JSv2) you may already have the klevu.js library included, and a klevu.interactive initialisation. If so, please merge the powerUp and recs nodes into that existing implementation you already have. The minimum version of Klevu JS Library for Klevu Recommendations to work correctly is 2.3.5+.