2. Mailchimp to Salesforce Integration - Update Unsubscribes in Salesforce

Business Problem

Mailchimp - Logo

Mailchimp is a great tool for people who are just starting out with email marketing and they currently use Salesforce as their CRM. We have done several implementations of Mailchimp and Salesforce and wanted to provide you with our best practice approach of how to set it up right the first time.

This is Part 2 of how to setup the Mailchimp to Salesforce integration where we will show you how to solve the following business challenge we ran into while implementing Mailchimp for Salesforce. Check out our Mailchimp How To section for additional tips on how to extend this integration.

  • Inability to update Contacts and Leads if they unsubscribe or their email bounces - Mailchimp integration does not provide a way to directly update the Email Opt Out field on the Contact or Lead in Salesforce. Zapier is a tool recommended to do this for you, but we ran into API limit issues with large volumes of contacts. Plus, you are limited to the actions Zapier provides between the two applications. We will use Salesforce Flow to update Leads and Contacts from the MC Subscriber data syncing to Salesforce from Mailchimp.

Or continue on for a short tutorial below.
Note: The video tutorial goes way more in depth.

How to Instructions

Update Unsubscribes & Bounce backs in Salesforce

In this section, we are going to create a flow that will update the Email Opt Out, Undeliverable Email Address and MC Member Status fields on the Lead or Contact from the MC Subscriber records created from Mailchimp. The Email Opt Out field is the standard field on the Lead and Contact objects in Salesforce. Unfortunately, we cannot create a package for you to install because we are building on the Mailchimp custom objects. Follow these steps to configure Salesforce to automate these updates.

Create the following fields on the Lead and Contact objects (if you are not using Leads, just do this for Contacts):

  • Undeliverable Email Address - checkbox
  • MC Member Status - picklist with the following values: Pending, Subscribed, Unsubscribed, Cleaned, Archived

You could opt to make the MC Member Status a formula field instead of a picklist since the Contact is directlyrelated to the MC Subscriber object via the MC4SF__MC_Subscriber__c field. Pro: You do not have to write automation to update the field. Con: Users have no idea what values are available for reporting. Since we had to write a flow anyways, we are going to make it a picklist and write automation for it.

Now its time to setup the automation using Salesforce Flow! If it's your first time using flow, don't worry - this will show you all of the steps. If you get stuck, let us know in the comments.

  • Go to Setup | New Flow in Salesforce

  • Select Record-Triggered Flow -> Create

  • Object = MC Subscriber
  • Configure Trigger = A record is created or updated
Flow Choose MC Subscriber

  • Make sure the Actions and Related Records is selected
  • Click Done
Flow MC Subscriber Entry

  • Click + sign to add element
Flow Plus Sign

  • Choose the Decision element.
Flow Decison Unsubscribe

  • Configure the first outcome called Unsubscribed and add the following conditions
  • Make sure to select
{!$Record__Prior.MC4SF__Member_Status__c} Does not equal {!$Record.MC4SF__Member_Status__c}
{!$Record.MC4SF__Member_Status__c} Equals Unsubscribed

  • Click the + sign to add another Outcome.
Flow Add Outcome

  • Configure the second outcome called Cleaned and add the following conditions
  • Make sure to select .
  • Cleaned in Mailchimp means the email address hard bounced and Mailchimp will prevent these email addresses from going into future campaigns. You can archive these records in Mailchimp, so they are not included in your contact count.
{!$Record__Prior.MC4SF__Member_Status__c} Does not equal {!$Record.MC4SF__Member_Status__c}
{!$Record.MC4SF__Member_Status__c} Equals Cleaned
Flow Clean Conditions

  • Click the + sign to add another Outcome.
Flow Add Outcome

  • Configure the third outcome called Subscribed and add the following conditions
  • Make sure to select .
{!$Record__Prior.MC4SF__Member_Status__c} Does not equal {!$Record.MC4SF__Member_Status__c}
{!$Record.MC4SF__Member_Status__c} Equals Subscribed
Flow Subscribe Conditions

  • Click the + sign to add another Outcome.
Flow Add Outcome

  • Configure the fourth outcome called IsChanged and add the following conditions
  • Make sure to select .
{!$Record__Prior.MC4SF__Member_Status__c} Does not equal {!$Record.MC4SF__Member_Status__c}
Flow IsChanged Condition

  • Your flow should look like this so far.
  • Click on the + sign under Unsubscribed to configure the update actions.
Flow Conditions All

  • Choose Update Records
Flow Unsusbcribe Actions Update Records

  • Label = Update Contacts
  • How to Find Records to Update and Set Their Values = Specify conditions to identify records, and set fields individually
  • Object = Contact
  • Filter Contact Records:

    • MC4SF__MC_Subscriber__c = {!$Record.Id}

  • Set Field Values for the Contact Records:

    • HasOptedOutOfEmail = True
    • Undeliverable_Email_Address__c = False
    • MC_Member_Status__c = {!$Record.MC4SF__Member_Status__c}

  • Click Done
Flow Unsubscribe Update Contacts1
Unsubscribe Update Contact2

  • Click on the Update Contacts element
Flow Unsubscribe Update Contacts3

  • Click Copy Element
Flow Unsubscribe Copy Element

  • Click the + Sign under Cleaned
Flow Cleaned Plus Sign

  • Select Paste Copied Elements
Flow Paste Copied Element

  • Click the Update Contact element you just pasted under Cleaned
  • Click Edit Element
Flow Cleaned Update Contacts1

  • Change the Set Field Values for the Contact Records to:

    • Undeliverable Email Address = True
    • MC_Member_Status__c = {!$Record.MC4SF__Member_Status__c}

Flow Cleaned Update Contact

  • Repeat the same copy/paste process and add an Update Contacts element under Subscribed.
  • Click Edit Element
  • Change the Set Field Values for the Contact Records to:

    • HasOptedOutofEmail = False
    • Undeliverable Email Address = False
    • MC_Member_Status__c = {!$Record.MC4SF__Member_Status__c}

Flow Subscribe Update Contact

  • Repeat the same copy/paste process and add an Update Contacts element under IsChanged.
  • Click Edit Element
  • Change the Set Field Values for the Contact Records to:

    • MC_Member_Status__c = {!$Record.MC4SF__Member_Status__c}

Flow Ischanged Update Contact

Here is what your final flow should look like:

Final Flow

  • Click Activate - now it is time to test and make sure the process is working!

Check out the 3rd part of our Mailchimp to Salesforce Integration series, where we show you how to create and update email metrics on Salesforce Campaign records from the MC Campaign records. Any comments, questions, concerns - let us know in the comments! We would love to hear from you!

How to Trigger Update All Existing Records

Now that you have the automation in place, you will want to trigger an update to all existing Contacts. Our flow is setup to only fire if the Member Status field is changed on the MC Subscriber record. In order to make the flow update all existing records, we recommend doing the following steps:

  1. Take a backup of the Contact and MC Subscriber objects using Data Loader. This is a precaution in case something happens, you can always put the data back to the way it was.
  2. Copy the MC Subscriber file and add a column that is blank and call it Blank Member Status.
  3. Make sure the Settings in Data Loader have Insert Null Values = True.
  4. Run a mass update to the MC Subscriber object to remove the value from the Member Status field.
  5. Run a mass update to the MC Subscriber object to replace the original value in the Member Status field.
  6. Confirm the Contacts were updated correctly.

For any questions, comments, concerns – let us know in the comment section below!
We would love to hear from you!

Share This Story, Choose Your Platform!

About the Author

Cheryl Fernandes

Cheryl is a certified Salesforce Application Architect and is the Founder and Lead Salesforce Consultant at Blu Ninjas. She has been working with Salesforce for 12 years and has helped companies in financial services, insurance and beauty industries implement solutions on the platform. Flow is her favorite Salesforce declarative tool, it is a game changer for anyone who does not know how to code.

6 thoughts on “2. Mailchimp to Salesforce Integration – Update Unsubscribes in Salesforce”

  1. Martine Theunisse

    Hi Cheryl, thanks a lot for your How to s!
    Is there a solution for scenario s when you change an e-mailadress from u subscriber in Salesforce. How can I get it automated that the prior e-mailadress gets unsubscribed?
    Thanks a lot!
    Martine Theunisse

    1. Hi Martine,

      In this scenario, I would create a new Contact record with the new email address. Salesforce is setup to track whether a single email address has opted out on a Contact record. If you wanted to track the prior email addresses in Salesforce, they would need to be on different contact records.

  2. I’m having an issue with this step:
    Set Field Values for the Contact Records:
    HasOptedOutOfEmail = True
    Undeliverable_Email_Address__c = False
    MC_Member_Status__c = {!$Record.MC4SF__Member_Status__c}
    None of these fields are available for me to select. Please advise, thanks!

    1. Hi Travis,

      We conversed via email, just putting the explanation here for others to see. There is a step at the beginning of the how to where you need to create the two custom fields on both the lead and the contact objects. Then you will be able to see the fields in the flows.

  3. Hi,
    Thank you for this, it is great!
    Have build the flow and it works. However, I have noticed that these fields are no longer available – {!$Record__Prior.MC4SF__Member_Status__c}.
    Thanks!

    1. Are you saying that the Member Status field does not exist on the MC Subscriber object in the Mailchimp Appexchange Package anymore? Can you check the list of fields in the MC Subscriber object and confirm if you see the field listed there?

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top