3. Mailchimp to Salesforce Integration - Campaign Sync

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 3 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.

  • Metrics for Mailchimp Campaigns are separate from other Salesforce Campaign metrics - The Mailchimp package comes with a custom object called MC Campaigns which holds the metrics you want to report on. If all of your other campaign data is in the standard Salesforce Campaign object, reporting is cumbersome. Plus, what if you move to another marketing automation tool? All of your metrics are in the Mailchimp package - if you uninstall the package from Salesforce all of your metrics will be gone as well.
  • Automate Salesforce Campaign creation - This how to will also show you how to automate the creation of a Salesforce campaign from an MC Campaign. If you start with a Salesforce Campaign and then sync the campaign members to Mailchimp, don't worry this process will not create duplicates, it will just keep the stats up to date.

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

How to Instructions

Update Salesforce Campaign Metrics from MC Campaign

  • We have two objectives to accomplish here:

    1. Create a Salesforce Campaign that is connected to the MC Campaign record if one does not exist.
    2. Update metrics on the Salesforce Campaign with the data from the MC Campaign object.

Follow these steps for how to complete this process:

  • Create the following fields in Salesforce on the standard Salesforce Campaign object:

    • MC Campaign - lookup field that looks up to the MC Campaign record
    • Emails Sent - number field no decimals
    • Opens - number field no decimals
    • Unique Opens - number field no decimals
    • Clicks - number field no decimals
    • Unique Clicks - number field no decimals
    • Unsubscribes - number field no decimals
    • Soft Bounces - number field no decimals
    • Hard Bounces - number field no decimals
    • Abuse Reports - number field no decimals
    • Forwards - number field no decimals
    • Forwards Opens - number field no decimals

Now you may be asking yourself, why aren't we creating formula fields here since we have a link between the Campaign and MC Campaign objects. There are several reasons:

  1. The data is not being stored on the Campaign object, it is referencing the data on the MC Campaign object. If we uninstall the Mailchimp package, then all of this data would be lost.
  2. If you were using another email automation tool and needed to migrate your data over, you would have your email metrics in two different fields for the same metric.
  3. We may want to update the fields at some point and if they are formulas we will lose that ability.

For ease of reporting, we recommend creating the following formula fields on the Campaign - you will then be able to see averages across all email campaigns and show these in a dashboard:

    • % Opens - formula = # Opens/Emails Sent
    • % Unique Opens - formula = # Unique Opens/Emails Sent
    • % Clicks - formula = # Clicks/Email Sent
    • % Unique Clicks - formula = # Unique Clicks/Email Sent
    • % Unsubscribes - formula = # Unsubscribes/Emails Sent
    • % Hard Bounces - formula = # Hard Bounces/Emails Sent
    • % Soft Bounces - formula = # Soft Bounces/Emails Sent

Use the IF function in your formulas to prevent the #Error! value when the Emails Sent = 0 like this:

IF( Emails_Sent__c = 0, 0, Opens__c / Emails_Sent__c )

  • Next, we will create a flow that will create and update the standard Salesforce Campaign from the MC Campaign record.

  • Go to Setup -> New Flow
New Flow

  • Select Record-Triggered Flow -> Create
New RecordTriggered Flow

  • Object = MC Campaign
  • Configure Trigger = A record is created or updated
Flow MC Campaign Entry

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

  • Click + sign to add element
Flow Plus Sign

  • Select Get Records
Flow Get Records Element

Now we need to configure the Get Records element to look for an already existing Campaign record. If one already exists, we do not want to create another one.

Configure the Get Records element:

  • Label = Get Campaign
  • Object = Campaign
  • Filter Campaign Records:

    • MC_Campaign__c Equals {!$Record.Id}

  • How Many Records to Store = Only the first record
  • How to Store record Data = Automatically store all fields
Get Campaign MC Campaign

  • Click + sign below the Get Campaign element to add a new element.
Flow Plus Sign Below Campaign

  • Select Decision
Flow Decison Unsubscribe

  • Configure the Outcome:

    • Label = Yes
    • Condition: {!Get_Campaign} Is Null = False
    • When to Execute Outcome = If the condition requirements are met
    • Change the label of the Default Outcome to No

Flow Get Campaign Decision

  • Click + sign below the No path to add a new element
Flow Plus Sign Campaign DNE

  • Select Create Records
Flow Create Records Element
    • Configure the Create Records element:
        • How Many Records to Create = One

       

        • How to Set the Record Fields: Use separate resources, and literal values

       

        • Object = Campaign

       

        • Set Field Values for the Campaign:
            • Abuse_Reports__c = {!$Record.MC4SF__Abuse_Reports__c}

           

            • Clicks__c = {!$Record.MC4SF__Clicks__c}

           

            • Emails_Sent__c = {!$Record.MC4SF__Emails_Sent__c}

           

            • EndDate = {!$Record.MC4SF__Send_Time__c}

           

            • Forwards__c = {!$Record.MC4SF__Forwards__c}

           

            • Hard_Bounces__c = {!$Record.MC4SF__Hard_Bounces__c}

           

            • Opens__c = {!$Record.MC4SF__Opens__c}

           

            • Soft_Bounces__c = {!$Record.MC4SF__Soft_Bounces__c}

           

            • StartDate = {!$Record.MC4SF__Send_Time__c}

           

            • Type = Email

           

            • Unique_Clicks__c = {!$Record.MC4SF__Unique_Clicks__c}

           

            • Unique_Opens__c = {!$Record.MC4SF__Unique_Opens__c}

           

            • Unsubscribes__c = {!$Record.MC4SF__Unsubscribes__c}

           

            • Forwards_Opens__c = {!$Record.MC4SF__Forwards_Opens__c}

           

            • Name = {!$Record.Name}

           

            • MC_Campaign__c = {!$Record.Id}

           

            • Status = Completed

           

           

       

       

 

If you are using Record Types on the Campaign object, please go to this article to see how you should use Custom Metadata Types to reference the Record Type Id, so you do not have to hard code it in the flow.

Flow Create Campaign1
Flow Create Campaign2

  • Click + sign below the Yes path to add a new element
Flow Plus Sign Campaign Exists

  • Select Decision
Flow Decison Unsubscribe

  • Configure the Decision element:

    • Name = Stats Modified?

  • Configure Outcome:

    • Label = Yes
    • Condition Requirements to Execute Outcome = Any Condition is Met (OR)
    • Add the following filter criteria:

      • {!$Record__Prior.MC4SF__Abuse_Reports__c} Does Not Equal {!$Record.MC4SF__Abuse_Reports__c}
      • {!$Record__Prior.MC4SF__Clicks__c} Does Not Equal {!$Record.MC4SF__Clicks__c}
      • {!$Record__Prior.MC4SF__Unique_Clicks__c} Does Not Equal {!$Record.MC4SF__Unique_Clicks__c}
      • {!$Record__Prior.MC4SF__Opens__c} Does Not Equal {!$Record.MC4SF__Opens__c}
      • {!$Record__Prior.MC4SF__Unique_Opens__c} Does Not Equal {!$Record.MC4SF__Unique_Opens__c}
      • {!$Record__Prior.MC4SF__Emails_Sent__c} Does Not Equal {!$Record.MC4SF__Emails_Sent__c}
      • {!$Record__Prior.MC4SF__Unsubscribes__c} Does Not Equal {!$Record.MC4SF__Unsubscribes__c}
      • {!$Record__Prior.MC4SF__Soft_Bounces__c} Does Not Equal {!$Record.MC4SF__Soft_Bounces__c}
      • {!$Record__Prior.MC4SF__Hard_Bounces__c} Does Not Equal {!$Record.MC4SF__Hard_Bounces__c}
      • {!$Record__Prior.MC4SF__Forwards__c} Does Not Equal {!$Record.MC4SF__Forwards__c}
      • {!$Record__Prior.MC4SF__Forwards_Opens__c} Does Not Equal {!$Record.MC4SF__Forwards_Opens__c}

    • When to Execute Outcome = If the condition requirements are met
    • Change the label of the Default Outcome to No

Flow MC Campaign Decision1
Flow MC Campaign Decision2

  • Click + sign below the Yes path to add a new element
Flow Plus Sign Stats Modified

  • Select Assignment
Flow Assignment Element

  • Configure the Assignment element:

    • Label = Assign Campaign Fields
    • Set Variable Values:

      • {!Get_Campaign.Abuse_Reports__c} Equals {!$Record.MC4SF__Abuse_Reports__c}
      • {!Get_Campaign.Clicks__c} Equals {!$Record.MC4SF__Clicks__c}
      • {!Get_Campaign.Unique_Clicks__c} Equals {!$Record.MC4SF__Unique_Clicks__c}
      • {!Get_Campaign.Forwards__c} Equals {!$Record.MC4SF__Forwards__c}
      • {!Get_Campaign.Forward_Opens__c} Equals {!$Record.MC4SF__Forwards_Opens__c}
      • {!Get_Campaign.Emails_Sent__c} Equals {!$Record.MC4SF__Emails_Sent__c}
      • {!Get_Campaign.Opens__c} Equals {!$Record.MC4SF__Opens__c}
      • {!Get_Campaign.Unique_Opens__c} Equals {!$Record.MC4SF__Unique_Opens__c}
      • {!Get_Campaign.Soft_Bounces__c} Equals {!$Record.MC4SF__Soft_Bounces__c}
      • {!Get_Campaign.Hard_Bounces__c} Equals {!$Record.MC4SF__Hard_Bounces__c}
      • {!Get_Campaign.Unsubscribes__c} Equals {!$Record.MC4SF__Unsubscribes__c}

Flow Assign Campaign1
Flow Assign Campaign2

  • Click + sign below the Assign Campaign Fields assignment element
Flow Plus Sign Assign Campaign Fields

  • Select Update Records
Flow Update Record Element

  • Configure Update Records element:

    • How to Find Records to Update and Set Their Values = Use the IDs and all field values from a record or record collection
    • Record or Record Collection = {!Get_Campaign}

Flow Update Campaign

  • Here is what your flow should look like so far:
Campaign Sync entire flow

  • If you are going to complete Part 7: Mailchimp to Salesforce Integration - Create Campaign Members (this article shows you how to add the contacts as campaign members and update their status), follow these steps:

    • Create a new field on the MC Campaign object called Campaign - this is a lookup to the Salesforce Campaign object. This is a helper field we use in the flow in Part 7.

MC Campaign Lookup

  • Click the Create Campaign element
Click Create Campaign

  • Scroll down to the bottom & check the box: Manually assign variables
  • Click New Resource
Manually assign variable

  • Create a new variable called varCampaignId
  • Data Type = Text
varCampaignId

  • Click the plus sign below the Create Campaign element
Plus Sign Create Campaign1

  • Select Update Records
Flow Update Record Element

  • Configure the Update Records element to have the following:
Update MC Campaign

  • Click Activate. You are now ready to start testing.

How to Test the Flow

There are two scenarios to test:

  1. Create Campaign in Mailchimp, send email and confirm a campaign is created in Salesforce.
  2. Start with a Salesforce Campaign that is related to a Mailchimp campaign and confirm stats are updated and duplicate campaign is not created.

If you followed the steps in Mailchimp to Salesforce Integration - Part 1 - you have a campaign record setup in Salesforce and Mailchimp. Go to this Campaign record in Salesforce and update the MC Campaign field to link the records.

  • Go to Campaign in Mailchimp and Click Send. Before sending, make sure you are a recipient in the campaign. Go to your email and open the test email and click one of the links in the email.

  • Go to the MC Campaign record in Salesforce - you will find it in the MC Campaign tab. Click the Refresh Campaign Stats and confirm the stats updated on the page. Please note: Campaign stats will refresh automatically every hour for the first 72 hours after the email campaign launched. If you navigate back to this page after 72 hours, click the Refresh Campaign Stats button to see the latest info from Mailchimp.

  • Go to your Salesforce Campaign record and confirm the stats updated there as well. If they did, congratulations you are done and ready to do your real campaigns!

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.

7 thoughts on “3. Mailchimp to Salesforce Integration – Campaign Sync”

  1. Hi there! This is great stuff. However it doesn’t seem like the links are working to the next part, adding leads to the campaign itself.

    1. Hi Jacob,

      We had to write apex in order to achieve adding campaign members to the campaign due to how the sync is running between Mailchimp and Salesforce. We have updated the article and made it live. Let us know how it goes. Thank you for your patience while we worked out the bugs.

  2. Cheryl, I noticed it shows setting values for forward and forward opens but it doesn’t show creating it (or I overlooked it). Thanks.

    1. Hi Mimi, Good catch here! I have added those two fields: Forwards and Forward Opens to the list of fields that need to be created on the Campaign. Thank you for letting me know the article was missing these!

Leave a Reply

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

Scroll to Top