Salesforce Commerce + Marketing Cloud Integration

The retail world is changing, and changing fast. How strongly and successfully your brand is transforming in this evolving landscape and connecting with your customer — It starts with e-commerce integration.

Adapting to today's buyer expectations. They want the ease of ‘buy anywhere, fulfill anywhere ” buying experiences — anytime, anywhere, through any medium on any device. Modern buyers want an effective interaction with your brand on any channel, and they expect your brand to engage with them as easily as they move across their preferred channels — mobile, social, online, or in-person. To provide this sort of customer experience, your e-commerce system needed to connect with marketing, inventory management, fulfillment, and back-end accounting systems.

Most of the legacy commerce platforms can not manage this type of e-commerce integration because their conventional systems were not designed for retail online integration, neither can they keep up with the pace of innovation that you require right now.

And because of that, when choosing omnichannel solutions that make eCommerce integration and innovation easy, many retailers today are in search of the right solution you don't need to go so far as you’re at the right place. We provide services related to the Salesforce commerce cloud and also help customers to resolve their complex business processes in a simple and most efficient way.

Implementation:

Here we are implementing the SFMC (Salesforce Marketing Cloud) API integration to SFCC (Salesforce Commerce Cloud) with the help of web services which is recommended by the SFCC to manage the API authentication, endpoints, timeout circuit breaker, and credentials. So we will be using the Marketing cloud API credentials and services from SFCC to handle the integration.

Prerequisites

We are assuming that the readers have the basic knowledge of Salesforce Marketing Cloud API creating and working process and Salesforce Commerce Cloud Business Manager key words.

Trails to learn about Marketing Cloud API

  1. Introduction to Marketing Cloud API’s

  2. To get API credentials for Marketing Cloud

  3. Marketing Cloud API’s trailhead

Trails to learn about Commerce Cloud

  1. Introduction to Commerce Cloud

  2. Commerce Cloud Basic Trailhead

  3. Development with Commerce Cloud

Steps: Create API Credentials in Marketing Cloud

Step 1: Login to Marketing Cloud with Admin permissions.

Step 2: Click on your username and select Administrator.

Step 3: In the Account tab, click new on 'Installed package' and create your app which will provide you the API details.

Administration > Account

Step 4 : Restrict/Allow the permission for the app you built as per your requirement.

Administration > Account > Edit API Integration

For more details you can follow this video guide.

Steps: Create Service in Commerce Cloud

Step 1: Login to your account manager with admin permissions.

Step 2: Go to the Administrator tab and select services.

Step 3: First create service credentials & service profile.

Step 4: After creating credentials and profile, create configuration.

All Required steps to create services:

Step: Create Service Credentials

Firstly we need to create credentials in services as we need to fill the API and secret key and authentication method in it.

Follow these steps for it.

  1. Select Administration > Operations > Services.

  2. On the Services webpage, click the Credentials button.

  3. On the Service Credentials, click on 'New'.

  4. On the New Service Credential page, insert a full name in which it can’t contain spaces. but do not include user or password information. For example: http.mysite.myservice.cred.

  5. Enter the URL in the service, following the protocol. For example, ftp://51.134.145.10 To use 1 service configuration for many URIs, you can extend this URL by getURL callback in the service registry.

  6. Enter the user name in the credential space.

  7. Enter the password, then it will be hidden after you type it and can’t retrieve from the Business Manager, so be certain to save it securely somewhere else.

For more details visit here.

Step 2 : Create Service Profile

  1. Select Administration > Operations > Services.

  2. On the Services webpage, click on the 'Profiles' tab.

  3. On the Service Profiles, click on 'New'.

  4. On the New Service Profile, enter a full name for the profile.

  5. Enter the number of milliseconds for the customer connection timeout. B2C Commerce waits for this number of milliseconds for a response from the web service before firing an error.

  1. Please mark the "Enable Circuit Breaker" option if you wish to activate the circuit breaker feature, which helps detect when a service is not available and halts further calls to the web service. It is advisable to enable the circuit breaker and customize its settings based on the service call rate.

  1. Enter the number of calls that fail to trigger the circuit breaker in the Max Circuit Breaker Calls field.

  2. Enter the number of milliseconds in which the maximum number of calls fail into the Circuit Breaker Interval (ms) field.

  3. Mark the Enable Rate Limit box if you would like to narrow the number of outgoing calls in a definite interval.

  4. Enter the maximum number of calls that B2C Commerce executes for the rate limit interval in the Max Rate Limit Calls field.

  5. Enter the number of milliseconds in which B2C Commerce can execute the maximum number of calls to the web service in the Rate Limit Interval (ms) field.

For more details visit here.

Step 3 : Create Service 

  1. Select Administration > Operations > Services.

  2. On the Services webpage, click on 'New'.

  3. On the New Service page, insert a name for the service.

  4. We recommend the naming pattern cartridge.protocol.service.operation.

  5. For example: mycartridge.http.payment.get or mycartridge.ftp.partner.getPriceList.

  6. If service names include periods in them, the period-delimited name segments become part of the logging hierarchy. Including the cartridge in the name is beneficial when you have various web service integrations because it groups logging info and assures unique service names.

  7. Select the service type to utilize for your web service. The type defines the underlying class used to call your web service and attaches methods to the methods inherited from the Service class.

  8. If the web service is available and you need to make calls to it, select the 'Enabled' button. It isn’t enabled by default.

  9. In the Service Mode rundown, to create calls to a live web service, select the 'Live' button. To use the mocked call configured in your service registry to simulate the expected response from the web service, select the 'Mocked'.

  10. Enter the name of a prefix for the log file in this service. If you do not enter a prefix, the log name will default to the main. Each log is written in the shared log directory to a file named service-prefix-internalID-date.log. If you don't enter a prefix, the file is named service-main-serviceID-date.

  11. If you require data in the request and response of the web service call to be logged, select 'Communication Log' Enabled.

  12. If you enable the communications log, Salesforce actively recommends adopting the log filtering callback methods to erase sensitive data from the log messages.

  13. To prevent unfiltered communication logs from being written on non-production instances, you can choose the 'Force PRD' behavior in non-PRD environments. When this setting is enabled, communication logs are only allowed if a filter is configured. Conversely, if you disable this setting, communication logs will be allowed even if no filter is configured. It's important to note that this setting does not affect production instances, and it only applies to non-production instances.

  14. Select one of the service profiles.

  15. Select one of the service credentials.

Using the services in code :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function lockUserAccount(args) {

try {
// Getting User Input
var emailData = require(‘~/cartridge/scripts / lib / EmailDataCreation’).getAccountLockedData(args);

emailData = JSON.stringify(emailData);
// 'accountLockedEmailServices' is the name of Service
var service = dw.svc.LocalServiceRegistry.createService(‘accountLockedEmailServices’, {

createRequest: function(svc, emailData) {

var payload = emailData;

svc.setRequestMethod(‘POST’);

svc.addHeader(‘Content - Type’, ‘application / json’);

return JSON.stringify(payload);

},

parseResponse: function(svc, result) {

return result;

},

filterLogMessage: function(msg) {

return msg;

}

});

// calling the service with required data
var response = service.call(emailData);

if (response.getStatus() == ‘OK’) {

return {
error: false
};

} else {

return {
error: true
};

}

} catch (e) {

Logger.error(“Error occurred
while calling lockUserAccount” + e.message);

return {
error: true
};

}

return {
error: false
};

}

For more details Please visit here.

In this blog, we uncovered how to successfully integrate the SFCC to SFMC via custom code to handle the mail requests from the same. After doing integration implementation, there are chances to save a lot of cost and dependencies from the other external system. And as they both are from the cloud family of salesforce so, it is convincing that the availability, robustness, security, and trust will not get compromised at any cost. Here, we have used the APIs of SFMC and services from SFCC that are very useful to the developers.

Got questions? Feel free to post below if any of the point is not clear, we’ll reply in more detail.

References:

  • https://documentation.b2c.commercecloud.salesforce.com/DOC1/index.jsp?topic=%2Fcom.demandware.dochelp%2Fcontent%2Fb2c_commerce%2Ftopics%2Fweb_services%2Fb2c_create_web_service_profile.html

  • https://documentation.b2c.commercecloud.salesforce.com/DOC1/index.jsp?topic=%2Fcom.demandware.dochelp%2Fcontent%2Fb2c_commerce%2Ftopics%2Fweb_services%2Fb2c_create_web_service_credential.html

  • https://www.youtube.com/watch?v=fHaPmPFP06k

  • https://trailhead.salesforce.com/content/learn/trails/develop-for-commerce-cloud

  • https://trailhead.salesforce.com/content/learn/modules/cc_ccbasics

  • https://trailhead.salesforce.com/content/learn/modules/marketing-cloud-apis

  • https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/api-integration.html

  • https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/apis-overview.html

  • https://www.salesforce.com/in/products/commerce-cloud/overview/

  • https://www.salesforce.com/in/products/marketing-cloud/overview/

Thanks to our Salesforce Consultant Abhishek Kumar Sharma for this excellent blog post brilliantly written with detailed information.

Abhinav Gupta

First Indian Salesforce MVP, rewarded Eight times in a row, has been blogging about Salesforce, Cloud, AI, & Web3 since 2011. Founded 1st Salesforce Dreamin event in India, called “Jaipur Dev Fest”. A seasoned speaker at Dreamforce, Dreamin events, & local meets. Author of many popular GitHub repos featured in official Salesforce blogs, newsletters, and books.

https://abhinav.fyi
Previous
Previous

Local Time & Weather is coming up with a massive upgrade!

Next
Next

Journey of Work From Home (The cultural shift of the workspace)