Skip to main content

1. Summary

This document provides technical instructions for using the Kleep SFCC Cartridge to integrate the Kleep AI Virtual Sizing into the SFCC storefront.

Glossary

TermDescription
SFCCSalesforce Commerce Cloud
Business Manager (BM)The primary tool used to configure the SFCC platform and customer storefront (SFRA)
SFRAStoreFront Reference Architecture

2. Component Overview

Functional Overview

Kleep’s integration into your SFCC-based e-commerce platform offers a powerful solution to enhance the shopping experience for your customers and minimize product returns. The functional overview breaks down the key features and functionalities:
  1. AI Sizing Analysis:
    • Kleep’s AI engine analyzes customer and product information to recommend the most suitable size for each product based.
  2. Product recommendations:
    • Kleep’s AI engine finds similar products to recommend within your catalogue when size is out of stock.
  3. Shopping Confidence:
    • Empowers customers with confidence in their purchasing decisions.
    • Reduces the likelihood of product returns by ensuring accurate sizing recommendations.
  4. Error Logging Mechanism:
    • Kleep provides a robust error logging mechanism, capturing, and saving all service errors in a dedicated log file.
    • Facilitates troubleshooting and maintenance by offering insights into any issues that may arise during operation.

Limitations, Constraints

Use of the Kleep cartridge requires credentials and keys from Kleep. Please contact your Kleep Account Manager. The cartridge is designed with multi-site, multi-locale and multi-currency support.

Compatibility

  • Salesforce Commerce Cloud API: The cartridge is specifically designed for version 22.7.
  • SFRA Compatibility: Optimized for SFRA version 7.0.0. While it may work with earlier SFRA versions, compatibility has not been formally verified.
  • SFCC API Versions: Potential compatibility with versions 21.7 and 21.2, though these have not undergone testing.
  • Limitations:
    • The cartridge is not suitable for use with Site Genesis and Headless storefronts.
    • Incompatibility with SFCC API versions 19.10 and earlier.
Please note: To ensure full functionality, testing with your specific environment is recommended if you are not using the directly supported versions. The frontend compilation has been tested with the same node version used for SFRA 7.0.0 => node v18.19.0.

Privacy, Payment

The Kleep cartridge collects and process user profile information for analytics. For additional privacy information, please contact your Kleep Account Manager. Please note that no cookie is used with tracking analytics (only localStorage).

3. Implementation Guide

Setup of Business Manager

Importing cartridges

  1. Download the cartridge source code.
  2. Extract the directory and move the link_kleep folder at the same level than SFRA
  3. You can remove the whole SFRA project from the Kleep connector (the storefront-reference-architecture folder). It is only used as a reference for testing.
image.png This should be the rendered cartridges structure: image.png
  1. Install the dependencies from the extracted directory:
cd /path/to/link_kleep
npm install
  1. Compile the frontend files from the Kleep project:
npm run compile
  1. Create a dw.json file in the same directory with the following content:
{
    "hostname": "...",
    "username": "...",
    "password": "...",
    "version": "..."
}
  • hostname is the hostname of your sandbox—for example: “zzaa-001.sandbox.us01.dx.commercecloud.salesforce.com”
  • username and password are your account manager credentials
  • version is the active code version listed in Administration > Code Deployment—for example, “version1”
  1. Upload the Kleep cartridges to your active code version:
npm run uploadCartridges
  1. Go to Administration > Development Setup > Folder Browser > Cartridges and verify that the Kleep cartridges are uploaded.

Assigning cartridges to the site

  1. Go to Administration > Sites > Manage Sites.
  2. Select your site from the Storefront Sites list:
image.png Select Settings tab. In the beginning of the cartridge path add the following: int_kleep_sfra:int_kleep image.png
  1. Go to Administration > Sites -> Manage Sites and click the link in Manage the Business Manager site section.
image.png Assign the cartridge to the Business Manager Site. Enter “bc_kleep:int_kleep” in the Cartridges textbox, separated by “:” if using multiple cartridges. Please refer to the screenshot below: image.png

Import of metadata

Go to Administration >  Site Development > Site Import & Export. Upload kleep-metadata.zip containing the metadata folder. image.png Select kleep-metadata.zip and finish the import process.

Configuration

Custom Site Preferences

After import is successfully done, you should see Site Preferences in BM > Merchant Tools > Site Preferences > Custom Preferences. image.png Select Kleep and you should see custom preferences for cartridge setup image.png
Site Preference IDSite Preference Display ValueSite Preference Description
isKleepRecommendationEnabledEnable Kleep Recommendation featureEnable/disable Kleep Recommendation feature used in PDP.
Doesn’t affect tracking and Job exports features.
kleepButtonColorKleep button colorThis is the Kleep button color in PDP, Cart, and Checkout. You can select Black or White, or override the CSS if you need custom frontend integration.
kleepFontFamilyKleep Font FamilyThe Font family used to override Kleep fonts (applied on Kleep button and Kleep iFrame). It is sent as a parameter when you click on the CTA to apply it into the iFrame.
isKleepSessionEnabledis Kleep Session Feature EnabledEnable/Disable session UUID logic creation. If set to false, will break tracking and dashboard / KPI computation.
kleepCountryCodekleep market codeMarket / Country Code following the ISO 3166 A-2 convention

Services

These are the Services used by Kleep to send requests and get iframe and other call responses. You can find them in Administration > Operations > Services. image.png kleep.sftp Service: Only used to send generated export files from SFCC webdav to Kleep SFTP server. The user should be sent by your Kleep Account Manager, with the associated .p12 certificate to use SSH instead of user/password. image.png Please replace the user by the one given by Kleep. Don’t set any password. kleep Service: Used for all other Kleep features. User and password are not set in the service credentials because the domain name (referrer) will be used to get the correct endpoint.

Private key and Certificate

Go to Administration > Operations > Private Keys and Certificates to prepare the usage of certificate for SSH connection to the Kleep server:
  • Click “Import” button
  • Click “Select” button and select the .p12 file provided by Kleep
  • Use “kleep” value in the alias input field
  • Click “Save” button
image.png The result should be something like this: image.png It has to be valid and named “kleep”.

Jobs

Go to Administration > Operations > Jobs, there are two SFCC jobs prepared to export:
  • The products used by your sites.
  • The orders history of your customers.
image.png They are disabled by default. For each job, you need to enable them so that they are executed once per day: image.png Then, you have to configure your Job as expected. For both of them:
  • Go to “Job Steps” tab
  • Click “RefArch” site to select the sites where you need to use Kleep.
    • Timeout: The ****timeout (in seconds) before stopping the export process.
    • OrdersMaxToExport: the maximum number of orders to export before stopping the export process.
image.png Now we need to configure this for the KleepExportProductsCSV: image.png
  • SkipMaster parameter is used to ignore the master products exports. Disabled by default.
  • OnlineOnly parameter is used to export only online products (ignoring offline ones). Disabled by default.
  • ExportType parameter is used to choose between a Delta (to update only updated products since the last export) or a Full export. “Delta” by default.
  • MainViewType parameter is used to export the main product image URL. “large” is the default value. Please replace it by the main view type you configured to display product images in the PDP.
  • Locale parameter is used to export specific locale information. The default locale is used if empty.
Important note: Please be aware that the number of exported products may exceed the number of processed products. This discrepancy often arises from products without categorization being included in the export due to their association with a master product. For instance, if both variants and a master product lack a primary category, but one or more associated VariationGroups have a primary category, then the master product, its variants, and the relevant variation groups will all be exported. This inclusion occurs despite these items not being counted initially. image.png

Stocks using OCAPI

Kleep queries stocks live to reflect current stock availability and check whether recommend sizes that are out of stock. To do so, we ask you to create an OCAPI user with specific authorizations:
  1. Open OCAPI Settings: Navigate to the Business Manager. Under the section Administration > Site Development > Open Commerce API Settings, edit the settings for the “Data” API.
  2. Set Up Client ID: For testing environments, you can use the following client ID: "client_id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" For production environments, you must generate a new client ID. Follow the Salesforce documentation on how to generate an API Client ID. A video is also available here: https://www.youtube.com/watch?v=Z3cZlQHWjtM
  3. Configure Resource Access: Add the following configuration snippet to your OCAPI settings under the “Data” API configurations. This setting grants read access to product inventory records, ensuring that Kleep can check the availability of specific sizes.
    Authorizations
    (GET) /inventory_lists/*
    (GET) /inventory_lists/*/product_inventory_records/*
    
  4. Confirm Configuration and sends to Kleep the list of following information:
    - Client ID
    - Client Secret
    - Inventory IDs (you might be using one per market, please provide your mapping)
    - URL of the production SBX (we enable stock checks on production only)
    

Custom Code

Update your templates

Note: all changes are already made in the int_kleep_sfra cartridge. You can remove the kleep SFRA templates in int_kleep_sfra/cartridge/templates/default folder if you have already overridden these files in your custom brand cartridge. KLEEP BUTTON (+ KLEEP PRODUCT TRACKING) To include the Kleep button in the PDP, you need to add this line to your custom app_custom_brand/cartridge/templates/default/experience/components/dynamic/product/productDetails.isml ****file, and in the app_custom_brand/cartridge/templates/default/product/productDetails.isml file:
<iscomment> CUSTOM KLEEP </iscomment>
<isinclude template="product/components/kleepButton" />
Right before this bloc of code:
<!-- Attributes and Quantity -->
<isinclude template="product/components/mainAttributes" />
You can include as many kleepButton templates as you want anywhere in the PDP, simply by duplicating the <isinclude> tag. All the buttons will be linked to only one iframe containing the Kleep Recommendation Modal. KLEEP CHECKOUT TRACKING To include the Kleep tracking into the checkout, please add this code:
<iscomment> CUSTOM KLEEP </iscomment>
<isinclude template="common/kleepTracking" />
Right after this code:
<!-- Step 3: Payment and Billing-->
<isinclude template="checkout/billing/billing" />
KLEEP CONFIRMATION TRACKING To include the Kleep tracking into the confirmation, please add this code:
<iscomment> CUSTOM KLEEP </iscomment>
<isinclude template="checkout/confirmation/kleepCheckoutCompletedTracking" />
Into the app_custom_brand/cartridge/templates/default/checkout/confirmation/confirmation.isml template right after this bloc of code:
<isscript>
*var* assets = require('*/cartridge/scripts/assets.js');
assets.addCss('/css/checkout/checkout.css');
assets.addJs('/js/checkoutRegistration.js');
</isscript>

4. Operations, Maintenance

Data Storage

Files

Data used for synchronization between SFCC site and Kleep are stored in CSV files in Administration >  Site Development >  Development Setup > Impex directory in the src/feeds/kleep/orders and src/feeds/kleep/products folders. The folder is created automatically after the first start of the job.

Custom Objects

  • 1 new Custom Object Type is created: KleepExportDateTracker
  • 2 custom objects are created and used to store the last export date for each job:
    • product” (containing the last export date for KleepExportProductsCSV)
    • order” (containing the last export date for KleepExportOrdersCSV)
image.png

5. User Guide

Storefront Functionality

1. FIND MY PERFECT SIZE

This is the main feature of Kleep. The display condition of the Kleep button in the Product Detail Page is effortlessly managed through a plug-and-play approach during cartridge initialization. Follow these steps to control the visibility of the Kleep button:
  1. Activate isKleepRecommendationEnabled Site Preference:
    • Ensure that the site preference isKleepRecommendationEnabled is activated within your Salesforce Commerce Cloud (SFCC) environment. This preference serves as the master switch to control the visibility of the Kleep button.
  2. Plug-and-Play Initialization:
    • The logic for handling the display condition of the Kleep button is seamlessly integrated during the cartridge’s initialization.
    • The code is designed to dynamically adapt to your environment, adding or removing the Kleep button based on your specified conditions (middleware added to the Product-Show controller action)
  3. Endpoint Call to Kleep:
    • Internally, the cartridge automatically makes an endpoint call to Kleep, passing the ProductID as a parameter.
    • The response from Kleep determines whether the button should be displayed or hidden.
  4. Customization:
    • Customize the conditions within your internal code logic to align the Kleep button’s visibility with your specific business rules.
By adhering to these steps, you can effortlessly manage the display condition of the Kleep button in the PDP. The plug-and-play initialization ensures that the logic seamlessly integrates into your existing setup, providing flexibility and control based on your business requirements. image.png When clicking on the Find my perfect size CTA, a popin opens with an iframe to begin the process. In the Kleep cartridge, the iframe process is using these parameters:
  • ProductID
  • KleepCustomerID
  • Domain name (referrer)
  • language
At the end of the process, you get the recommendation from Kleep. When hitting “Ajouter la taille S au panier”, the iFrame sends an event and the selected size is added to cart.

3. Dynamic changing button label

When you close the popin, the button label is changed with the recommended size: image.png The Kleep cartridge offers a dynamic button label update feature that conveys size recommendations to users as they navigate through product pages or complete the sizing journey (after closing the popin). The evolution of the button label is as follows:
  • Initial Label: “Find My Perfect Size”
  • Updated Label: “Recommended Size: S” (S is an example)
By integrating this feature, the Kleep cartridge ensures that the button label dynamically reflects size recommendations and seamlessly responds to user interactions throughout the sizing journey. Note: Technically, localStorage is utilized exclusively to store data related to Kleep, with no backend session variables or cookies being stored

4. Tracking

Analytics data is automatically sent to Kleep when:
  • a product is viewed (PDP loaded, or new variation selected)
  • a product is added to cart (in PDP)
  • an order is ready to be placed (end of checkout, before placing order)
  • an order is confirmed (order confirmation page)
This feature doesn’t change the storefront features for users, but it helps Kleep to improve the recommendations. After you installed the cartridge, please check you don’t get any frontend javascript errors into the console in PDP, checkout and confirmation pages.

5. Anti-Bracketting

Coming soon…

6. Known Issues

  • The Kleep button and the product tracking events (product_viewed and product_added_to_cart) are not working with the quick view (from the PLP).
  • The KleepExportProductsCSV job with “ExportType” parameter set to “Full” is limited to catalogs with less than 20 000 master products because of the api.jsCollectionSize quota

7. Release History

VersionDateChanges
24.6.02024-06-10• Initial release
24.7.02024-07-03Enhancements:
Product Export Optimization: Updated the KleepExportProductsCSV job to export only delta products based on their lastModified date, rather than exporting the entire catalog daily. This enhances efficiency by reducing data processing and transfer load.
Image URL Handling: Switched from relative to absolute URLs for product images in Kleep tracking, ensuring consistent access across different platforms and services.
Custom Objects Usage: Enhanced the utilization and management of Custom Objects within the system for improved data handling.
API Call Optimization: Optimized Kleep API calls by eliminating unnecessary service calls in certain scenarios, enhancing performance and reducing overhead.
New Features:Event Tracking: Added tracking functionality for multiple events: ◦ product_added_to_cart: Tracks when products are added to the cart. ◦ checkout_completed: Monitors when a checkout process is successfully completed. ◦ checkout_validated: Tracks when a checkout process is validated. Fixes:Frontend Compilation: Addressed compilation issues in the frontend, improving build stability and developer experience. • Job Export Stability: Resolved crashes in initial job exports by ensuring that the custom object is automatically created if not already present, ensuring reliability in data export processes. | | 24.8.0 | 2024-08-30 | Fixes:PDP Console Errors: Resolved console error logs on Product Detail Pages (PDP). Enhancements:Kleep Recommendation Feature: Modified the Kleep Recommendation feature to use VariationGroups instead of Masters, optimizing the recommendation logic and accuracy. | | 24.9.0 | 2024-09-25 | Fixes: - AddToCart Feature: Resolved an issue with the AddToCart functionality from the pop-up.
  • Metadata Archive: Fixed the absence of the ‘kleepLastExported’ attribute in the metadata archive.
Enhancements: - KleepExportProductsCSV Job Compatibility: Updated the ‘KleepExportProductsCSV’ job to be compatible with SFCC API version 21.2, enhancing stability and performance. | | 24.10.0 | 24-10-07 | Enhancements:
  • API Compatibility: Improved compatibility with API Version 21.2 when generating the Kleep recommendation modal URL (PDP)
  • Export Performance Improvement: Enhanced the KleepExportProductsCSV job by:
    • Adjusting the export jobs chunk size from 1000 to 100 for better monitoring and performance.
    • Removing empty and duplicate lines to clean up data quality and reduce file size.
    • Improving export speed for a more efficient data processing experience.
    • Improving logs for better debugging, enabling more precise tracking and understanding of execution processes.
    • Adding automatic trimming of values from the MainViewType
New Features:
  • Flexible Export Options: Introduced an ExportType parameter in export jobs, allowing users to choose between Delta and Full export without manually deleting the KleepExportDateTracker CustomObject.
  • Enhanced Data Inclusion: Added assigned categories’ names and IDs to the export file from the KleepExportProductsCSV job, enriching the dataset for uncategorized products.
Fixes:
  • Job Status Reporting: Fixed an issue where a job’s status displayed as “OK” in the BM user interface while it was “ERROR” in the backend.
  • Custom Object ‘KleepExportDateTracker’ Creation: Corrected a bug that prevented the creation of the ‘KleepExportDateTracker’ custom object when an error occurred in jobs.
  • KleepExportProductsCSV Job: Enhanced the ‘KleepExportProductsCSV’ job to include variants from variation groups when master products are uncategorized. | | 24.10.1 | 2024-10-21 | Enhancements:
  • KleepExportProductsCSV Job Improvements:
    • Enhanced to include all variants and variation groups from a master product when at least one variant or variation group is categorized.
    • Updated the export quota limit to 20,000 master products.
    • Introduced a new “SFCC_Product_VariationGroups_ID” column in the CSV export file to better represent product hierarchies
    • Remove useless “[BRAND]” configuration in job step
  • KleepExportOrdersCSV Job Improvements:
    • Filter on orders with “Exported” status only
    • Remove useless “[BRAND]” configuration in job step
  • PDP Improvements:
    • Added the ability to add multiple Kleep Recommendation CTA anywhere in the PDP
    • Removed CTA loading spinner
    • Improved accuracy with recommendation results by:
      • Checking the inventory in real time before suggesting a specific product.
      • Adding new button_clicked tracking event.
      • Updating the tracking events data structure.
Fixes
  • Resolved an issue in the KleepExportOrdersCSV job that occurred when processing orders with notes. | | 24.10.2 | 2024-10-23 | - Updated recommendation modal URL | | 24.11.0 | 2024-11-06 | Fixes:
  • Resolved an issue where the “SFCC_custom_attributes” column was missing data in the KleepExportProductsCSV and KleepExportOrdersCSV export jobs.
  • Ensured that the KleepExportOrdersCSV job functions correctly when using the Full export option, without any restrictions.
Enhancements:
  • Removed the limitation of exporting only 1000 orders in KleepExportOrdersCSV; now exports without any restrictions.
  • Enhanced logging capabilities for both KleepExportProductsCSV and KleepExportOrdersCSV export jobs.
  • Introduced a retry feature in KleepExportOrdersCSV to handle failed order exports without affecting the processing of other orders. | | 24.11.1 | 2024-11-08 | Enhancements:
  • Localized PDP CTA: Added translations for the CTA button on product detail pages in French, Japanese, Spanish, Portuguese (Portugal and Brazil), Italian, Korean, German (Germany, Belgium), and Dutch (Netherlands).
  • Removed PDP CTA logo | | 24.11.2 | 2024-11-12 | Fixes:
  • Added a new boolean custom attribute, isKleepExported, to track whether orders/products have been exported. This change addresses inconsistencies in querying orders based on the kleepLastExported or kleepLastExportedFailure attributes.
  • Fixed an issue where a stringified empty object was exported for custom attributes. It’s now an empty string.
Enhancements:
  • Custom Timeout: Implemented a custom timeout parameter for jobs, set to 15 minutes (900 seconds) by default
  • Maximum Order Limit: Introduced a parameter to limit the number of orders processed per job execution, set to 1000 orders by default
  • Order Reset Job: Added a new job to reset the export status of orders, setting kleepLastExported to null and isKleepExported to false, preparing them for re-export.
  • Delta Export Mode: Removed the Delta/Full parameter for orders; all exports are now automatically handled in delta mode. If a job stops due to an error, reaching the maximum number of processed orders, or timeout, the remaining orders will be exported in the next run. | | 25.09.0 | 2025-09-22 | Enhancements
  • New session logic with creation of unique session UUID upon each new session creation, allowing to track and compute session-based client KPIs. Session UUID is shared with iFrames and allows to reconciliate External and Internal tracking.
  • Support of multiple categories: Shoes, Kids, Lingerie
  • Harmonization of domains handler
  • 2 new custom preferences to define site market (used to differentiate KPIs per market and for flow personalizations) and session logic enabler
  • Enhanced internal tracking reliability with postMessage-based triggers |