- DarkLight
Setting Up Loyalty & Referrals on SFCC Controllers and Pipelines
- DarkLight
Yotpo’s suite of integrated solutions for loyalty and referrals helps commerce companies accelerate growth by enabling advocacy and maximizing customer lifetime value. With Yotpo's Loyalty and Referrals solutions, brands can effectively leverage social proof to increase trust and sales, cultivate loyal customer advocates, and make better business decisions based on real customer feedback.
This document provides a technical overview and step-by-step instructions for installing Yotpo's Salesforce Commerce Link Cartridge - enabling you to integrate various Yotpo features within a Salesforce Commerce storefront.
For instructions on how to install Yotpo Loyalty & Referrals Cartridge for Salesforce SFRA, please see this article.
Merchants using Yotpo's Salesforce Commerce Link Cartridge can access the following features:
- Loyalty Program (Earning and redeeming points)
- Referral Program
- In order to use the Salesforce Commerce Link Cartridge, you must be subscribed to an eligible Yotpo premium plan.
- Use of the Yotpo LINK cartridge by itself does not grant nor enable the use of Yotpo product offerings. You must first enter a contractual agreement with Yotpo in order for the loyalty and referral program to run.
- To learn more, please reach out to Yotpo Sales at: sales@yotpo.com
Cartridge overview
- The cartridge is compatible with Site Genesis version 13.6 or later.
- For the storefront functionality to work properly, the Purchasers Feed Export Generation integration must be set up within your Salesforce Business Manager.
The Loyalty & Referrals integration makes use of the following cartridges:
Cartridge | Description | Service |
---|---|---|
bm_yotpo | Business Manager | Swell Loyalty & Referrals |
Terms of service
In using the Yotpo LINK cartridge, you agree to Yotpo's terms of service.
Step 1: Configuration
Files download
Make sure to download the installation files.
Cartridge registration
Navigate to the following path: Administration > Manage Sites > Business Manager > Settings
Add the cartridge name: bm_yotpo within the Cartridges path as shown below:
The cartridge includes a custom interface within the Salesforce Business Manager to manage logins to the Yotpo Loyalty & Referrals control panel.
SiteGenesis Controller cartridge configuration
The Yotpo cartridge relies on a “guard” script from SiteGenesis Controller cartridge if the integration is being implemented with the Controller version.
- The default name used in Salesforce is: app_storefront_controllers
- If the controller cartridge name differs from the default name, you need to change the constant in Yotpo's code. This is the constant that needs to change; exports.SITEGENESIS_CARTRIDGE_NAME = "app_storefront_controllers";
- You need to change it in Yotpo's code under int_yotpo/cartridge/scripts/yotpo/utils/Constants.js
Uploading Metadata configurations
The downloaded files include a metadata.zip file that needs to be uploaded to your Salesforce admin.
To upload the file, go to Administration > Site development > Import & Export > Manage Import Files and upload the metadata.zip file:
Once the file is uploaded, click the Import button next to "Meta data". You'll be guided through a Salesforce Commerce Cloud installation wizard.
This process automatically adds all the necessary Yotpo attributes to your platform.
Services details
In this section, we are defining where Yotpo's cartridge will send Salesforce information (such as orders, customers, etc) to Yotpo's backend.
- Navigate to Administration > Operations > Services > Click on the Credentials tab
- Click New
- In the Name field (Required) add the following: int_yotpo.https.post.swell.api.cred
- In the URL field add: https://app.swellrewards.com/commerce-cloud/
- User and Password fields are not required
- Once the setting is saved, this is what you will see in Salesforce:
Name | Profile | Credentials |
---|---|---|
int_yotpo.https.post.swell.api | int_yotpo.rest.api.profile | int_yotpo.https.post.swell.api.cred |
Step 2: Setting up the integration
Adding logged-in customer and cart tracking
Yotpo Loyalty needs to have information about the customer on the website's front end. We need to know if the customer is logged in and we also need to know the cart information. We need this information in order to present the customer with their points balance, redemption options, etc. In order for Yotpo to get this information, the following template must be included within the storefront footer file i.e. footer.isml in SiteGenesis:
<isinclude template="include/yotpofooter" />
After you place the above html template snippet in your page (in the example below, it's in the footer), it will be rendered on your site as follows (swell customer identification and swell cart identification tags were added):
Adding Data Observers
Yotpo needs to get all orders and customers in order to be able to reward points, give coupons, place customers in tiers, etc. The loyalty cartridge is responsible for sending this information from SFCC to Yotpo by using two site genesis controllers described below. The details of controllers are described below.
Order observer
The order observer hook should be added into COSummary-Submit (checkout summary submit) controller after order creation with the following code snippet:
var SwellExporter = require('int_yotpo/cartridge/scripts/yotpo/swell/export/SwellExporter');
var result = SwellExporter.exportOrder({
orderNo: order.orderNo,
orderState: 'created'
});
Customer observer
The customer observer hook should be added into Account-RegistrationForm and Account-EditForm controllers using the following code snippet:
var SwellExporter = require('int_yotpo/cartridge/scripts/yotpo/swell/export/SwellExporter');
var result = SwellExporter.exportCustomer({
customerNo: customer.profile.customerNo
});
After adding the above code snippet your controllers will look like this:
Account registration form
Account edit form
Adding Yotpo cartridge required endpoints
On top of orders and customers that Yotpo is listening to through the above controllers, Yotpo needs to get more information from the cartridge in order for the loyalty and referral program to perform properly. This step is crucial in the setup of the integration.
In this section, we are mapping the methods required in the cartridge to URLs (endpoints) that will be available in SFCC for Yotpo to pull data.
Steps to adding the required endpoints mapping
Navigate to Merchant Tools > SEO > URL Rules > Pipeline URLs
Add the following mappings URLs in Pipeline URLs
Alias (URL in BM) | Pipeline (Method in Yotpo's Cartridge) | Why is this needed |
---|---|---|
swell/index/customer | SwellYotpo-GetCustomer | When Yotpo needs specific information on a single customer |
swell/index/customers | SwellYotpo-GetCustomers | When a new merchant onboards, Yotpo pulls past customers |
swell/index/order | SwellYotpo-GetOrder | When Yotpo needs specific information on a single order (for processing refunds for example) |
swell/index/orders | SwellYotpo-GetOrders | When a new merchant onboards, Yotpo pulls past orders |
swell/index/thirty-day-order-volume | SwellYotpo-GetOrderCountByVolume | Verifying communication between SFCC and the cartridge |
swell/index/create-gift-certificate | SwellYotpo-CreateGiftCertificate | When the merchant uses gift certificates, this endpoint is used |
After adding the endpoints, your setting page will look like this:
Step 3: Setting up refunds
If you'd like to deduct or re-issue points redeemed at checkout for refunded orders, you'll need to send Yotpo Loyalty & Referrals the refund data. If you're using product-specific requirements or restrictions for campaigns, you'll also need to include specific item information along with the required refund data. This should be done by sending a new refund to the Swell API via the POST: Create A Refund endpoint outlined below to modify the previously processed order.
This endpoint records a refund for an existing order. It will apply the refund to the relevant order and then adjust any reward given by the original order.
Please see the API specifications and parameters here.
Step 4: Enabling loyalty
In order for the cartridge to work you need to enable Loyalty:
- Navigate to Merchant Tools > Site Preferences > Custom Preferences > Yotpo Configs
- Enable the Yotpo Loyalty & Referrals settings by updating the Swell Loyalty Enabled field to "Yes"
Custom Attribute Name | Function |
---|---|
Yotpo Cartridge Enabled | Enables/disables the Yotpo cartridge |
Swell Loyalty Enabled | Enables/disables Swell Loyalty |
Yotpo Static Content URL | The base URL to load static content from Yotpo |
Yotpo Conversion Tracking Pixel URL | Conversion tracking pixel URL |
Import Reviews Realtime | Designates whether reviews are imported in real-time |
Product Information From Master | Makes production information configurable whether the information will be exported from master or from variants. |
Export Group ID in Order | Used to make the logic configurable that whether the master product if will be exported as JSON or not. |
Yotpo Orders Batch Size | This attribute contains batch size for the number of orders that should be processed at one time, while exporting purchase feed. |
Yotpo Swell Static Content URL | The URL used to load static content for Swell JavaScript |
Yotpo Info Log Enabled | The flag controls the info log level in whole Yotpo cartridge. By default, the info log will be disabled, therefore to enable the checkbox should be checked. |
Yotpo Debug Log Enabled | The flag controls the debug log level in whole Yotpo cartridge. By default, the debug log will be disabled, therefore to enable the checkbox should be checked. |
Step 5: Giving Yotpo OCAPI permissions
Yotpo uses OCAPI (Salesforce's Open Commerce API) as part of the loyalty integration. In order to give Yotpo permissions to OCAPI, you need to create a user on Salesforce that has the relevant OCAPI permissions. Then you will provide Yotpo with the user and password in the integration phase (step 7).
The user login and password credentials have to be that of an actual user (meaning, can be used to log into the SFCC Business Manager).
These credentials expire every 90 days. The loyalty/integrations/integration_disabled event will be sent to the webhook URL and the integration will be disabled.
You will have to update the new password in the Loyalty & Referrals admin to ensure that Yotpo is able to access your SFCC store to generate rewards, as well as retrieve customers and orders.
Endpoints
Yotpo uses two types of endpoints on OCAPI - Shop and Data. The following endpoints are needed for the Yotpo integration: See here the full documentation on Salesforce.
Endpoint | Description |
---|---|
/baskets/#{basket_id}/payment_instruments | Add payment instrument to basket. When the customer redeems points for a gift certificate and applies it to the basket - this endpoint is used. |
/baskets/#{basket_id}/payment_instruments/#{payment_instrument_id} | Remove Payment instrument from basket. When the customer removes a gift certificate from the basket, this endpoint is used. |
/baskets/#{basket_id}/items | Add product to basket. When there is a free product redemption (customers redeems points for product), this endpoint is used to add the product to the basket. |
/baskets/#{basket_id}/items/#{item_id} | Remove product from basket. If the customer decides they do not want the free product, this endpoint is used to remove the product from the basket. |
/baskets/#{basket_id}/price_adjustments | Add price adjustment to basket. When using fixed amount/ percentage/ variable redemption, this endpoint is used in order to give the discount to the customer. |
/baskets/#{basket_id}/price_adjustments/#{price_adjustment_id} | Remove price adjustment from basket. If the customer decides to remove the discount from the basket, this endpoint is used to remove it. |
/baskets/#{basket_id} | Get information on basket. Used to understand which redemptions are part of the basket in order to know how many points to present to the customer. |
/baskets/ /baskets/#{basket_id}/storefront | Create basket. Mainly used for free product redemptions, when there is no basket and the customer redeemed a product, we create the basket for the customer. |
/baskets/#{basket_id}/coupons | Automatically add coupon to basket. Used for the referred friend coupon to auto apply it to the basket. |
Adding the endpoints to Salesforce
In order to give Yotpo permissions for all of the above endpoints, You will need to upload two files to the business manager. One to the shop OCAPI and one to the data OCAPI. Navigate to Administration > Site Development > Open Commerce API SettingsUnder the Shop settings, copy the endpoints from this file.
Under the Data settings, copy the endpoints from this file.
A basic configuration for these OCAPI settings is included in the metadata import.
This configuration is located under the “client_id” section inside of the “Open Commerce API Settings” and must be set to the appropriate client ID for both the “Shop” and “Data” dropdown selections.
We recommend changing the default Client ID from its default setting. This also applies to staging/dev accounts.
Make sure this ID matches the one you use in the integration page of your Yotpo Loyalty admin.
Step 6: Enabling login to Yotpo via Salesforce
In this section, we explain how to add a Yotpo login function to your Salesforce admin. This is important in SFCC to have Yotpo credentials. Permission to access the Loyalty module must be granted to a specific role.
- Navigate to the following path: Administration > Organization > Roles & Permissions
- Select the relevant role to be granted e.g. Administrator
- Open the Business Manager Module tab as shown below in the animation below.
- Choose the relevant site
- Check the box adjacent to Yotpo Swell Login
- Click Update
Step 7: Yotpo Loyalty & Referrals admin registration
Lastly, complete the integration through the Yotpo Loyalty & Referrals admin dashboard which can be accessed via the Business Manager module:
- Navigate to Merchant Tools > Site Preferences > Yotpo Swell Login
- Select the specific locale configured in Yotpo Configurations (custom object). Your Yotpo Loyalty & Referrals GUID and API Key will be automatically populated.
- Click the Login button to access your Yotpo Loyalty & Referrals admin.
- Within the Loyalty Admin, click Integrations
- Select Commerce Cloud from the dropdown list of integrations
- Fill in the fields with the relevant details/ identifiers and click Add Integration when you're done
Field | Description |
---|---|
Instance Type | Select Production or Sandbox environment. Note that each instance must be connected to a different Yotpo Loyalty & Referrals account. |
Client ID | Salesforce Client ID |
Client Password | Salesforce Client Password |
User Login | Salesforce User Login - this user needs to have permission to add price adjustments to a basket. |
User Password | Salesforce User Password |
Hostname | Your store's URL e.g. https://amizingstore.com You may choose to temporarily protect your site with a username and password. You can add those details to the Yotpo Loyalty admin so that Yotpo can have access to your protected site. Simply add the storefront credentials to the Salesforce integration page in your Yotpo Loyalty admin in the following format: If the storefront URL is: https://yotpo03-tech-prtnr-eu03-dw.demandware.net/ and the storefront credentials are as follow: user_name: user password: strong_password then the Hostname value should be added like this: https://user:strong_password@yotpo03-tech-prtnr-eu03-dw.demandware.net/ |
Site ID | Salesforce Site ID. The Site Id can be found in your SFCC admin under Administration > Sites > Manage Sites Note: If you have implemented any URL redirections after the initial locale, make sure to add them to this field as part of the integration. |
OCAPI Version | Specify which Open Cart API version is used in the following format:v19_1The value must match the latest OCAPI version available. |
Cartridge Version | Please select V1 to ensure that you are seeing all of the relevant features for this integration |
The user login and password credentials have to be that of an actual user (meaning, can be used to log into the SFCC Business Manager).
These credentials expire every 90 days. The loyalty/integrations/integration_disabled event will be sent to the webhook URL and the integration will be disabled.
You will have to update the new password in the Loyalty & Referrals admin to ensure that Yotpo is able to access your SFCC store to generate rewards, as well as retrieve customers and orders.
Registration error
If you see an error message in your Yotpo Loyalty & Referrals admin at the point of registration, follow the instruction below to see how to resolve it and continue with the integration:
Error | Solution |
---|---|
Invalid client id, client password, user login, or user password | This means that the OCAPI credentials are invalid. You can review this section of the process here. |
Either one of these fields is wrong (Hostname, Site ID, OCAPI Version) or Cartridge configured incorrectly in Commerce Cloud admin | This means that the URL mapping may not have been added correctly. You can review this section of the process here. |
Suffix - Data storage
Yotpo uses custom attributes - special fields used to add details to objects. This is an SFCC feature that allows you to add additional info to objects.
This allows us to receive additional information about the shoppers, orders, and redemptions to fully correlate these details within our system to present in our Loyalty dashboards (link)
Below you can see a breakdown of the attributes added as part of the cartridge that we then use to showcase within the boards:
Order custom attributes
ID | Name | Description | Type |
---|---|---|---|
userAgent | User Agent | This attribute stores the user agent information at the time of order placement | String |
userIPAddress | User IP Address | This attribute stores the user IP address information at the time of order placement | String |
PriceAdjustment custom attributes
ID | Name | Description | Type |
---|---|---|---|
swellPointsUsed | Swell Points Used | The number of points used as part of the redemption | Integer |
swellRedemptionId | Swell Redemption Id | The detail required to associate Yotpo's internal redemption ID with the price adjustment happening on site | String |
ProductLineItem custom attributes
ID | Name | Description | Type |
---|---|---|---|
swellPointsUsed | Swell Points Used | The number of points used as part of the redemption | Integer |
swellRedemptionId | Swell Redemption Id | The detail required to associate Yotpo's internal redemption ID with the price adjustment happening on site | String |
OrderPaymentInstrument custom attributes
ID | Name | Description | Type |
---|---|---|---|
swellPointsUsed | Swell Points Used | The number of points used as part of the redemption | Integer |
swellRedemptionId | Swell Redemption Id | The detail required to associate Yotpo's internal redemption ID with the price adjustment happening on site | String |
GiftCertificate Custom Attributes
ID | Name | Description | Type |
---|---|---|---|
swellPointsUsed | Swell Points Used | The number of points used as part of the redemption | Integer |
swellRedemptionId | Swell Redemption Id | The detail required to associate Yotpo's internal redemption ID with the price adjustment happening on site | String |
Configuring order processing flow
The Settings section of your Yotpo Loyalty & Referrals admin allows you to choose an order status that will trigger point deduction and an order status that will trigger the rewarding of points.
- Point deduction
Set a trigger that will deduct the points a shopper used to redeem coupons or discounts when making the purchase. Yotpo will deduct the points as the status is registered in our system.
We recommend deducting points at the point of order creation to avoid a time gap where shoppers may try to redeem points that are no longer available to them.
- Rewarding points
If you are using a payment processing provider such as WorldPay, the payment approval process for a new order may take some time. Ideally, we do not want to reward a shopper with points before the payment has been approved.
Setting up an order status 'COMPLETED' as the trigger for rewarding points will ensure that points will be given only after the payment has been processed and confirmed.
We recommend setting the trigger post-payment approval so as not to reward customers with points for an unsuccessful purchase.