1. Home
  2. /
  3. Admin Guide
  4. /
  5. Plugins
  6. /
  7. Mailchimp

Mailchimp

Introduction

This guide aims to walk you through the process of effectively integrate Mailchimp with Cirrus Shield.

Prerequisites

Before you can start using the service, you will need to do the following steps:

In Mailchimp

1. Create a Mailchimp Account

To get started, you will need to create a Mailchimp account. If you do not have one already, you can sign up by visiting the following link: https://mailchimp.com/

2. Obtain Your API Key

After successfully creating your Mailchimp account, the next step is to acquire your API key. This key will enable you to connect seamlessly with our service. To obtain your API key, follow these steps:

a. Access the API Key Management Page

Click on the following link to access your Mailchimp account’s API key management page: https://us9.admin.mailchimp.com/account/api/?_ga=2.224117659.1627744431.1691751332-217670292.1678692587

b. Generate a New API Key

Once on the API key management page, select the option to “Create A Key.” This will prompt you to provide a name for your API key.

c. Retrieve and Save Your API Key

After naming your API key, the system will generate the key for you. It is crucial to copy and save this key in a secure location. You will need it during the configuration process

In Cirrus Shield

  1. Install the Mailchimp Plugin :

Start by navigating to the “Configuration” section in Cirrus Shield, then select “Extensions.” From there, install the Mailchimp plugin to enable the integration between the two platforms.

2. Create Essential Objects: Contact, Lead, and Campaign :

To utilize the Mailchimp Plugin effectively, you need to ensure that at least one of the following objects is created: “Contact,” “Lead,” or “Campaign.” These objects require specific fields with designated types, particularly the crucial fields: “First_Name,” “Last_Name,” and “Email.” Refer to the image provided below for samples of the required fields.

Furthermore, it is essential to link the created campaign to the “Contact” and/or “Lead” objects.

To create an object, access “Configuration,” then choose “Objects,” and proceed to create the desired object.

After creating the object, go to “Champs personnalisés” and create a new field, based on the fields that are shown in the image.

N.B : Make sure to create the fields with the same name and same type of the images regarding the objects

It should be the same done for the rest of the fields based on their name and field types.

3. JavaScript Button :

Create a button for the object that you will be using with Mailchimp, the objects can be “Contact,” “Lead” or “Campaign.” To create a JavaScript button, navigate to Configuration -> Object -> Details -> Bouton Personnalisés

Then you create a button with the following information

Here will be the codes that you can use with each object respectively:

Contact :

function SendContactsBasedOnFilter()
{
    let TokenGUID = GetTokenID();
    let orgInfo = new Object();
    let userInfo = new Object();
    
    let list_name = document.getElementsByClassName("cuselText")[0].getElementsByTagName('label')[0].innerHTML;
    
    let divElement = document.getElementById("divSubDataTablePartialListView0")
    let rows = divElement.querySelectorAll('tr');
    let contactGUIDs = [];
    let contacts = [];
    let userLanguage = null;

    $.ajax({
        beforeSend: function (xhrObj) {
            xhrObj.setRequestHeader("Accept", "application/json");
        },
        type: "GET",
        async: false,
        dataType: "json",
        contentType: "application/json",
        url: "/RestApi/Query?authToken=" + TokenGUID + "&selectQuery=SELECT Name, Email, Language FROM User",
        success: function (Data) {
            if (Data.Data != undefined) {
                userInfo = Data.Data.User[0];
userLanguage = userInfo.Language;
            }
            else {
                userInfo = null;
            }
        },
        error: function (XMLHttpRequest) {
            alert(XMLHttpRequest.statusText);
        }
    });

    rows.forEach(row => {
        contactGUIDs.push(row.id);
    });

    contactGUIDs.shift();

    contactGUIDs.forEach(GUID => {
        var contact = GetDataByID(GUID,"Contact", "First_Name, Last_Name, Email");
        contacts.push(contact);
    });

if(contacts == null || contacts.length === 0){
 var message = "There are no contacts.";
 if (userLanguage === "fr") {
   message = "Il n' y a pas de contacts.";
 }
alert(message);
return;
}

    $.ajax({
        beforeSend: function (xhrObj) {
            xhrObj.setRequestHeader("Accept", "application/json");
        },
        type: "GET",
        async: false,
        dataType: "json",
        contentType: "application/json",
        url: "/RestApi/Query?authToken=" + TokenGUID + "&selectQuery=SELECT Id, Name, Country, City, Street, PostalCode FROM Organization",
        success: function (Data) {
            if (Data.Data != undefined) {
                orgInfo = Data.Data.Organization[0];
                if (Data.Data.Organization[0].Country == null) {
                    orgInfo.Country = "France";
                }
            }
            else {
                orgInfo = null;
            }
        },
        error: function (XMLHttpRequest) {
            alert(XMLHttpRequest.statusText);
        }
    });

    try {
        var settings = {
            "url": `https://mchmp.cirrus-shield.net/Mailchimp?list_name=${list_name}`,
            "method": "POST",
            "timeout": 0,
            "headers": {
                "Content-Type": "application/json"
            },
            "data": JSON.stringify({ "Contacts": contacts, "User": userInfo, "Organization": orgInfo }),
            "error": function (XMLHttpRequest) {
                alert("Error: " + XMLHttpRequest.responseText);
            }
        };

        $.ajax(settings)
            .done(function (response) {
                var message = "Contacts have been successfully sent to Mailchimp.";
if(userLanguage === "fr"){
message = "Les contacts ont été envoyés à Mailchimp avec succès";
}
                alert(message);
            });
    } catch (error) {
        console.log(error);
        alert(response);
    }
}

Lead :

function SendLeadsBasedOnFilter()
{
    let TokenGUID = GetTokenID();
    let orgInfo = new Object();
    let userInfo = new Object();
    
    let list_name = document.getElementsByClassName("cuselText")[0].getElementsByTagName('label')[0].innerHTML;
    
    let divElement = document.getElementById("divSubDataTablePartialListView0")
    let rows = divElement.querySelectorAll('tr');
    let contactGUIDs = [];
    let contacts = [];
    let userLanguage = null;

 $.ajax({
        beforeSend: function (xhrObj) {
            xhrObj.setRequestHeader("Accept", "application/json");
        },
        type: "GET",
        async: false,
        dataType: "json",
        contentType: "application/json",
        url: "/RestApi/Query?authToken=" + TokenGUID + "&selectQuery=SELECT Name, Email, Language FROM User",
        success: function (Data) {
            if (Data.Data != undefined) {
                userInfo = Data.Data.User[0];
userLanguage  = userInfo.Language;
            }
            else {
                userInfo = null;
            }
        },
        error: function (XMLHttpRequest) {
            alert(XMLHttpRequest.statusText);
        }
    });

    rows.forEach(row => {
        contactGUIDs.push(row.id);
    });

    contactGUIDs.shift();

    contactGUIDs.forEach(GUID => {
        var contact = GetDataByID(GUID,"Lead", "First_Name, Last_Name, Email");
        contacts.push(contact);
    });

if(contacts == null || contacts.length === 0){
 var message = "There are no leads.";
 if (userLanguage === "fr") {
   message = "Il n' y a pas de prospects.";
 }
alert(message);
return;
}

    $.ajax({
        beforeSend: function (xhrObj) {
            xhrObj.setRequestHeader("Accept", "application/json");
        },
        type: "GET",
        async: false,
        dataType: "json",
        contentType: "application/json",
        url: "/RestApi/Query?authToken=" + TokenGUID + "&selectQuery=SELECT Id, Name, Country, City, Street, PostalCode FROM Organization",
        success: function (Data) {
            if (Data.Data != undefined) {
                orgInfo = Data.Data.Organization[0];
                if (Data.Data.Organization[0].Country == null) {
                    orgInfo.Country = "France";
                }
            }
            else {
                orgInfo = null;
            }
        },
        error: function (XMLHttpRequest) {
            alert(XMLHttpRequest.statusText);
        }
    });

    try {
        var settings = {
            "url": `https:// mchmp.cirrus-shield.net /Mailchimp?list_name=${list_name}`,
            "method": "POST",
            "timeout": 0,
            "headers": {
                "Content-Type": "application/json"
            },
            "data": JSON.stringify({ "Contacts": contacts, "User": userInfo, "Organization": orgInfo }),
            "error": function (XMLHttpRequest) {
                alert("Error: " + XMLHttpRequest.responseText);
console.log(XMLHttpRequest);
            }
        };

        $.ajax(settings)
            .done(function (response) {
              var message = "Leads have been successfully sent to Mailchimp.";
if(userLanguage === "fr"){
message = "Les prospects ont été envoyés à Mailchimp avec succès";
}
                alert(message);
            });
    } catch (error) {
        console.log(error);
        alert(response);
    }
}

Campaign:

function SendCampaignMembers()
{
    var TokenGUID = GetTokenID();
    var orgInfo = new Object();
    var userInfo = new Object();
    var test = document.querySelectorAll("#cell1id");
    var list_name = test[0].textContent;
    var contacts = [];
    var userLanguage = null;
    var campaign_members = GetDataByColumn("Campaign", GetRecordGUID(), "Campaign_Member", "Name, Member");

$.ajax({
        beforeSend: function (xhrObj) {
            xhrObj.setRequestHeader("Accept", "application/json");
        },
        type: "GET",
        async: false,
        dataType: "json",
        contentType: "application/json",
        url: "/RestApi/Query?authToken=" + TokenGUID + "&selectQuery=SELECT Name, Email, Language FROM User",
        success: function (Data) {
            if (Data.Data != undefined) {
                userInfo = Data.Data.User[0];
                userLanguage = userInfo.Language;
            }
            else {
                userInfo = null;
            }
        },
        error: function (XMLHttpRequest) {
            alert(XMLHttpRequest.statusText);
        }
    });



    if (campaign_members == null || campaign_members.length === 0) {
var message = "There are no campaign members.";
if(userLanguage === "fr"){
message = "Il n'y a aucun membre de campagne.";
}
        alert(message);
        return;
    }

    campaign_members.forEach(element =>
    {
        var contact = GetDataByID(element.Member, "Contact", "First_Name, Last_Name, Email");
        if (contact == null)
        {
            contact = GetDataByID(element.Member, "Lead", "First_Name, Last_Name, Email");
        }
        contacts.push(contact);
    });

    $.ajax({
        beforeSend: function (xhrObj) {
            xhrObj.setRequestHeader("Accept", "application/json");
        },
        type: "GET",
        async: false,
        dataType: "json",
        contentType: "application/json",
        url: "/RestApi/Query?authToken=" + TokenGUID + "&selectQuery=SELECT Id, Name, Country, City, Street, PostalCode FROM Organization",
        success: function (Data) {
            if (Data.Data != undefined) {
                orgInfo = Data.Data.Organization[0];
                if (Data.Data.Organization[0].Country == null) {
                    orgInfo.Country = "France";
                }
            }
            else {
                orgInfo = null;
            }
        },
        error: function (XMLHttpRequest) {
            alert(XMLHttpRequest.statusText);
        }
    });
    
    try {
        var settings = {
            "url": `https://mchmp.cirrus-shield.net/Mailchimp?list_name=${list_name}`,
            "method": "POST",
            "timeout": 0,
            "headers": {
                "Content-Type": "application/json"
            },
            "data": JSON.stringify({ "Contacts": contacts, "User": userInfo, "Organization": orgInfo }),
            "error": function (XMLHttpRequest) {
                alert("Error: " + XMLHttpRequest.responseText);
            }
        };

        $.ajax(settings)
            .done(function (response) {
var message = "Contacts have been successfully sent to Mailchimp.";
if(userLanguage === "fr"){
message = "Les contacts ont été envoyés à Mailchimp avec succès";
}
                alert(message);
            });
    } catch (error) {
        console.log(error);
        alert(response);
    }
}

And then make sure to change the visibility of the button based on the users that will be using it, you can do this by going to the object where you created the button -> button details -> Profils

And finally you will be able to see the button in the details page of the record of the specific chosen object

Configuration

To configure the plugin that you installed, you’ll have to go to the details of the Mailchimp installed plugin.

This will direct you to the configuration page. Initiate the configuration process by entering your Cirrus Shield credentials (Username & Password) and your Mailchimp credentials (Access Token). After inputting the necessary information, click “Create” to save the configuration to Cirrus Shield.

Was this article helpful to you? No Yes

How can we help?