📋 How to Import MailChimp Subscribers to Google Sheets
1. Overview
\[ \begin{array}{l} \textbf{Google Sheets can be connected to MailChimp using their API --} \\ \text{to automatically import and update subscriber lists for analysis or reporting.} \\ \textbf{By using Google Apps Script, you can pull subscriber details --} \\ \text{such as name, email, status, and signup date directly into your sheet.} \end{array} \]
2. Core Steps
\[ \begin{array}{ll} \textbf{Step 1:} & \text{Log in to your MailChimp account and generate an API key.} \\ \textbf{Step 2:} & \text{Find your MailChimp data center prefix (e.g., us1, us2) from the API key.} \\ \textbf{Step 3:} & \text{Get the Audience/List ID where your subscribers are stored.} \\ \textbf{Step 4:} & \text{Open Google Sheets and go to Extensions $\rightarrow$ Apps Script.} \\ \textbf{Step 5:} & \text{Write a script to call the MailChimp API and load subscriber data into the sheet.} \end{array} \]
3. Sample Google Apps Script
// Replace with your MailChimp API Key and List ID
var API_KEY = 'YOUR_API_KEY';
var LIST_ID = 'YOUR_LIST_ID';
var DC = 'YOUR_DATA_CENTER'; // e.g., 'us1'
function importMailChimpSubscribers() {
var url = 'https://' + DC + '.api.mailchimp.com/3.0/lists/' + LIST_ID + '/members';
var options = {
'method': 'get',
'headers': {
'Authorization': 'apikey ' + API_KEY
},
'muteHttpExceptions': true
};
var response = UrlFetchApp.fetch(url, options);
var data = JSON.parse(response.getContentText());
if (data.members) {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
sheet.clear();
sheet.appendRow(['Email Address', 'Full Name', 'Status', 'Signup Date']);
data.members.forEach(function(member) {
sheet.appendRow([
member.email_address,
member.merge_fields.FNAME + ' ' + member.merge_fields.LNAME,
member.status,
member.timestamp_signup
]);
});
} else {
Logger.log("No members found or invalid credentials.");
}
}
4. Important Notes
\[ \begin{array}{l} \text{• You must have MailChimp API access enabled in your account.} \\ \text{• The API key contains your data center prefix (e.g., us1, us2).} \\ \text{• API rate limits apply; avoid excessive calls in a short time.} \\ \text{• Store API keys securely and avoid sharing them publicly.} \end{array} \]
5. Conceptual Flow (in LaTeX)
The process can be described as:
\[ \text{MailChimp API} \xrightarrow{\text{Apps Script}} \text{Subscriber Data in Google Sheets} \]
Where: \[ \text{Subscriber Data} = \{ \text{Name}, \text{Email}, \text{Status}, \text{Signup Date} \} \]