Capturing subscriber data from Marketing Cloud with MuleSoft

  • Written By Sahadev Sreepathi
  • 21/12/2021

In this rapidly growing digital age, communication with our audience is paramount, but often people receive overwhelmingly unwanted communication (emails, SMS, social media posts, etc.). To avoid essential communication getting lost as spam, but also to comply with mandates and regulations like GDPR, the use of subscription preferences to ensure consent around the communication between a company and an individual has become a standard.

With such growing complexity, organisations are increasingly turning to solutions to help identify and curate the right channel of communication and relevant content for their customers, so they can improve their experience and engagement. Among these solutions, Salesforce Marketing Cloud is the leading platform for today’s complex digital marketing and communications requirements.

In this article we will look in detail how we can synchronize subscriber details and preferences captured in Salesforce Marketing Cloud with other business systems of an organisation.

What is Salesforce Marketing Cloud?

Quoting Salesforce, Marketing Cloud is a leading global digital marketing platform which includes tools for email marketing, social media marketing, mobile marketing, online advertising, and marketing automation. Marketing Cloud enables businesses to create data driven, personalised, customer journeys across multiple channels. It leverages one platform so businesses can provide a consistent, cohesive, customer experience across email, social, website, advertising and even in-store.

What is a Marketing Cloud API and why is it useful?

Salesforce Marketing Cloud provides a set of tools to manage customer interaction throughout the customer journey, from marketing and sales to commerce and service. Marketing Cloud helps organisations to really know their audience, personalise the communication with relevant information, and provides ways to interact across various touch points. To enable such capabilities, Marketing Cloud utilises a wealth of data and much of this data is accessible via the Marketing Cloud API.

Capturing and sharing Subscriber from Salesforce Marketing Cloud using Mule 4

In this example, we will look at how we can get subscriber details from Marketing Cloud and process this data in MuleSoft’s Anypoint Platform (runtime engine Mule 4), to send it to other business applications.

The implementation involves two key steps:

  1. Creating a ‘connected app’ in Salesforce Marketing Cloud which can be used by Mule to access Marketing Cloud subscriber updates
  2. Capturing the subscriber data from Marketing Cloud and processing it into other business applications (in this example we use a database) in Mule

1. Steps to create a Connected App in Marketing Cloud Setup

These instructions assume that you have access with appropriate Roles in Salesforce Marketing Cloud to create Installed Packages

  • Login to Salesforce Marketing Cloud
  • Click on Settings -> Setup -> Apps -> Installed Packages. Click on ‘New’ and add a new Package by providing Name and Description. It creates a Package.
Create-NewPackage-Marketing-Cloud
  • Now Click on the ‘Add Component’ button that appears under the ‘Details’ tab. A pop-up opens with a few options under the “Choose your Component Type” section.
  •  Select ‘API Integration’ as component type and click on ‘Next’ button.
  •  Select ‘Server-to-Server’ as Integration Type and click on ‘Next’ button.
  •  Select Appropriate Scopes as needed for Integration and click ‘Save’.
  • Once Saved you will be able to see the ‘API Integration’ under the ‘Components’ section. It includes the Client ID, Client Secret, SOAP Base URI, and Authentication Base URI. Please make note of them, as we will be using them with Mule 4 in the next section.     
Connected-App-Details

2. Processing the Marketing Cloud Subscriber event message using MuleSoft

Now that we have our Connected App which enables us to capture updates on objects in Marketing Cloud, let’s look at processing the events using a listener in Mule 4

Below are the steps required to create a listener in Mule 4:

  • Create an empty Mule 4 application and add Salesforce Marketing Cloud connector dependency in pom.xml
    <dependency>
    <groupId>com.mulesoft.connectors</groupId>
           <artifactId>mule-sfdc-marketing-cloud-connector</artifactId>
    <version>3.2.1</version>
    <classifier>mule-plugin</classifier>
    </dependency>
  • Inside a Mule flow add the “Salesforce Marketing Listener – On new object” and configure it to listen to the “Subscriber” Object.
  • In the example below, the payload from the “On new object listener” (with marketing cloud subscriber data) component is transformed and used to create / update the Subscriber in the database by calling a stored procedure.
Mule flow
  • Below is the xml snippet of Salesforce Marketing Listener – On new object listener and its connector configuration.
  • Use the values that were generated in Step 1 in the connector configuration. Client Id as clientId, Client Secret as clientSecret, SOAP Base URI as the serviceUrl and Authentication Base URI + “v2/token” as the tokenUrl parameters respectively.
<sfdc-marketing-cloud:config name=”marketing-cloud-config” doc:name=”Salesforce Marketing Cloud Config” doc:id=”0adee505-cc40-440c-acbb-dc305078fbc5″>
            <sfdc-marketing-cloud:oauth-client-credentials-connection serviceUrl=”https://testinstance.soap.marketingcloudapis.com/Service.asmx” >
                  <sfdc-marketing-cloud:oauth-client-credentials clientId=”clientid” clientSecret=”clientsecret” tokenUrl=”https://mysubdomain.auth.marketingcloudapis.com/v2/token” />
                  <sfdc-marketing-cloud:oauth-store-config objectStore=”oauth_objectStore” />
            </sfdc-marketing-cloud:oauth-client-credentials-connection>
    </sfdc-marketing-cloud:config>

<sfdc-marketing-cloud:new-object-listener doc:name=”On new subscriber” doc:id=”b94d0f55-be47-4a5b-8b6d-ab1e6506a1bc” objectType=”Subscriber” since=”2021-05-04″ config-ref=”marketing-cloud-config”>
                  <scheduling-strategy >
                        <fixed-frequency timeUnit=”SECONDS” frequency=”10″ startDelay=”5″/>
                  </scheduling-strategy>
            </sfdc-marketing-cloud:new-object-listener>

 The Mule application is now ready to be started/deployed.

  • When the Mule application starts, it listens to the changes on the ‘Subscribers’ object in Marketing Cloud. On create/update of Subscriber the event is captured, and the transformed payload is inserted or updated into DB using a stored procedure.
  • The mule application is deployed and following are snippets of a subscriber creation.
  • Below is a Subscriber created in Marketing Cloud
Create Subscriber - Marketing Cloud
  • Below is the payload (marketing cloud subscriber details) that is logged inside the Mule application when a subscriber is created/updated in Salesforce Marketing Cloud.
Logger
  • The subscriber information is synced to the database using a stored procedure.

In this article, we briefly went through what is Salesforce Marketing Cloud and delve into how you can capture Subscriber details in Mule to process the data and send it to other business applications.

If you would like to find out more about how you can integrate Salesforce Marketing Cloud with other systems in your business, give us a call or email us at marketing@whishworks.com.

Other useful links:

MuleSoft and WHISHWORKS

Salesforce Classic to Lightning migration – things to consider

What is an API and how does it enable connectivity?

Latest Insights

Application Integration
Blogs

What is Application Integration?

Application integration helps close the gap between existing on-site systems and the ever-evolving cloud-based enterprise applications.

Coforge Salesforce High Velocity Sales
Blogs

Enabling sales with Salesforce High Velocity Sales

What exactly High Velocity Sales is, how it can benefit your business and how to enable it.

CRISP-DM : ANALYTICAL FRAMEWORK
Blogs

Using the CRISP-DM framework for data driven projects

Learn how CRISP-DM can facilitate the planning, organising, and implementing process of data-driven projects.