Import Mailchimp Data to Google Sheets
In this guide, we’ll walk through how to pull data from the Mailchimp API directly into Google Sheets, using the free API Connector add-on for Google Sheets. We’ll first get an API key from Mailchimp, and then set up a request to pull in email campaign details from your Mailchimp account to your spreadsheet.
- Part 1: Get your Mailchimp API Key
- Part 2: Create your API Request URL
- Part 3: Enter values into API Connector
- Part 4: Notes and Expansions
PART 1: GET YOUR MAILCHIMP API KEY
- Log into your Mailchimp account and navigate to the API Keys section (or just click this link: https://us1.admin.mailchimp.com/account/api/)
- Click the Create A Key button
- You’ll now see your API key listed in a section titled “Your API keys”
- Congrats, that’s it! You now have access to the Mailchimp API, and can start pulling Mailchimp data into Google Sheets.
PART 2: CREATE YOUR API REQUEST URL
We’re going to follow the Mailchimp API documentation to retrieve information about members in an email list.
Mailchimp base URL: https://us{data_center_ID}.api.mailchimp.com/3.0
Example: https://us20.api.mailchimp.com/3.0/
Endpoint: /lists/{list_id}/members
Example: /lists/32d8e317e4/members
Putting it all together, we get the full API Request URL:
https://us20.api.mailchimp.com/3.0/lists/32d8e317e4/members
Of course, you’ll need to substitute in your own values for {data_center} and {list_id}, which you can find as follows:
- {data_center_ID}: check the URL when you’re logged in to your Mailchimp account
- {list_id}: navigate to Settings > Audience Name and Defaults. Once you click this, you’ll see your list ID (which they’ve now begun calling an “Audience ID”).
PART 3: ENTER VALUES INTO API CONNECTOR
We’re now ready to enter all our values into API Connector to start importing Mailchimp data into Google Sheets.
- Open up Google Sheets and click Add-ons > API Connector > Create New API Request
- In the Create Request interface, enter the Request URL we just created
- Under Headers, enter Authorization as your Key, and apikey {your API key} as your Value, like this (the curly brackets indicate where need to substitute in your actual API key):
Authorization apikey {your API key} It should look like this:
- Create a new tab. You can call it whatever you like, but here we’ll call it ‘Mailchimp Members’. While still in that tab, click ‘Set’ to use that tab as your data destination.
- Name your request. Again we’ll call it ‘Mailchimp Members’
- Click Run and a moment later you’ll see your Mailchimp data populate the Mailchimp tab in your Google Sheet:
PART 4: NOTES AND EXPANSIONS
- If you want to see other data, like a list of campaigns, you’d just change the endpoint. For example, https://us20.api.mailchimp.com/3.0/campaigns will give you a list of your campaigns.
- Note Mailchimp’s limits on the number of records returned on a response. By default, only 10 records will be returned unless you use the ‘count’ and ‘offset’ parameters as described in their documentation.
To get more records, use the ‘count’ and ‘offset’ parameters, like this:
page 1: https://us20.api.mailchimp.com/3.0/campaigns?offset=0&count=1000
page 2: https://us20.api.mailchimp.com/3.0/campaigns?offset=1000&count=1000With API Connector, you can either set these up as separate requests or run them simultaneously (paid feature) for added efficiency.
- The Mailchimp API Playground is a great resource to test out different API calls.
why me just get 10 data from mailchimp?
The Mailchimp API documentation says:
Paginate your API requests to limit response results and make them easier to work with. We use offset and count in the URL query string to paginate because it provides greater control over how you view your data.
Offset defaults to 0, so if you use offset=1, you will miss the first element in the dataset. Count defaults to 10. For example, this URL includes query string parameters for pagination: https://usX.api.mailchimp.com/3.0/campaigns?offset=0&count=10
What this means is that by default, Mailchimp only provides 10 records at a time. To get more, change the parameters at the end of your URL, e.g.:
https://us20.api.mailchimp.com/3.0/campaigns?count=50
Then to get the next 50 results, you’d enter:
https://us20.api.mailchimp.com/3.0/campaigns?offset=50&count=50
Super product, kudos! Is there a possibility to work with arrays such as are provided through e.g. this (in emails >> activity): https://usXX.api.mailchimp.com/3.0/reports/%5Bcampaign_id%5D/email-activity?count=500&fields=emails.campaign_id,emails.list_id,emails.email_address,emails.activity.timestamp,emails.activity.action,emails.activity.url,emails.activity.type
Thank you so much! I am working on an update now that will provide more options for displaying arrays and nested data. You can see more info here: https://mixedanalytics.com/knowledge-base/report-styles/
Will that work for you?
Oh yes! Looking forward to it!
This is now live : )
This is great! Thank you!