500

Salesforce and Mailchimp integration for a design and production service company

About The Company:

The Client, a distinguished UK-based design and production service company, is renowned for creating high-quality art.

Customer Challenges:

The Client faced crucial challenges, they needed a solution to automatically manage the synchronization of email subscription statuses between Salesforce Contacts/Leads and their Mailchimp lists. 

When a Contact/Lead record had its 'Email Opt Out' checkbox marked, the Client wanted it to be unsubscribed from the associated Mailchimp list. Conversely, if the 'Email Opt Out' checkbox was unchecked, the corresponding record should be resubscribed to the Mailchimp list.

The 'MailChimp for Salesforce App lacked the desired functionality, prompting the client to craft a customized solution.

Solution:

To address these challenges, the following innovative solution approaches were proposed and evaluated by us:

Apex Trigger & Helper Class:

An Apex trigger was developed for both the Contact and Lead objects.

A supporting helper class was created to facilitate callouts to the Mailchimp REST API.

Callout methods were implemented in the helper class using the @future annotation, which allows callouts from Apex triggers.

The process flow involved:

  • Detecting when the 'Email Opt Out' checkbox was checked on a Contact/Lead record.
  • Initiating a callout to the Mailchimp API to unsubscribe the corresponding member from the Mailchimp list.
  • Utilizing the MD5 hash of the email address (member ID) to interact with the Mailchimp member using the Mailchimp REST API.
  • Bulk processing of records using Mailchimp Batch Operations Endpoint to unsubscribe multiple members efficiently.

Apex Batch/Scheduler Class:

An Apex Batch, a Helper, and a Scheduler classes were designed to meet the requirement.

  • The start method of the Apex batch queried all Contact/Lead records with the 'Email Opt Out' checkbox marked.
  • The execute method in the batch is called the Helper class method with email IDs to perform Mailchimp API callouts and unsubscribe the members.
  • An Apex Scheduler class was created to schedule the Batch to run periodically.
  • The Apex batch processed records in chunks, enhancing processing efficiency.
  • Similar to the first approach, MD5-formatted email IDs were used, and the Mailchimp Batch Operation Endpoint was employed.

Results:

The integration solution delivered notable outcomes such as:

  • Contact/Lead records were successfully unsubscribed from the associated Mailchimp list when the 'Email Opt Out’ checkbox was marked.
  • Unchecking the 'Email Opt Out' checkbox enabled the seamless resubscription of Contact/Lead records in the Mailchimp list.
  • The first approach, which utilized Apex Trigger & Helper Class, was selected as the preferred solution by the Client.

Final Words:

In response to the Client's imperative need for Mailchimp-Salesforce integration, CloudCache Consulting devised and executed a tailored solution. The integration seamlessly managed email subscription statuses, aligning with the Client's unique requirements. By overcoming technical obstacles, We enabled the Client to enhance its customer communication strategy and maintain data consistency across platforms. Our Salesforce Professional Resources were a key help in this. Connect with us on Fiverr.

Find us on Facebook

Find us on Twitter

Find us on Linkedin