How to pull Mailchimp Data into Google Sheets with Google Apps Script

30 thoughts on “How to pull Mailchimp Data into Google Sheets with Google Apps Script

  1. Can the app run automatically on a schedule or do you have to manually trigger it every time? It would be great to use this data in a data studio report

  2. [17-03-29 15:48:25:617 EAT] TypeError: Cannot read property "length" from undefined.
    How to fix it?

  3. This looks great! Would be such a timesaver.

    For me the data is being pulled and returned in the log but it's not appearing in the sheet. The name of my sheet is 'Campaign Analysis' as it is in the code. The error is:

    TypeError: Cannot call method "getRange" of null

    I'm using api_002_mailchimp/ from github.


  4. Julian, I have 7 years of history with Mailchimp and don't really need to fetch all the data. How to limit the campaigns I get with this script to the recent ones?

  5. Are you able to run the script just using the API Key and not using the List ID. Most companies probably don't follow Mailchimp's best practice for keeping 1 clean list and it would be cool if you could just get all the campaign data from all the different lists… Thanks!

  6. This works great! Is it possible to make a separate sheet that imports the subscribers info into each row as well? Email, Name, Last Name, etc…

  7. Could you please one video on fetching the facebook marketing campaigns data into Spreadsheet using Facebook Marketing APIs? Since there is no free tool for it, I think it will be very useful for all of us.

  8. Hi Ben

    Simply amazing! Hey could you help me please? I need to fetch subscriber's activity (campaigns sent, opens, clicks, etc.) for each subscriber 🙂


  9. Hello, I get this error in log and just can not figure out, how to fix this.

    TypeError: Cannot read property "length" from undefined. mailchimp script

    I have copied all the source code, add API key and list ID. List works almost fine, but Campaigtn sheet has no data :/

    Will be greatfull for your help.

  10. I'm try to create the same report about list growth but per week, but i can not get the data from API per week.
    Plz help me with that. someone did it?
    Amazing tutorial

  11. Awesome thanks Ben and Julian. You speak a little fast but it's all good stuff!! I just got my first API to work very happy!!!

  12. Great video! Any idea how to restrict the scripts to a specific list? It seems to be pulling from all lists despite adding the specific list ID

  13. I'm working on a script that refreshes, fetches, and sorts by date every 15 minutes or so. I'll post when ready if anybody is interested

  14. I got this error: SyntaxError: Unexpected token: < (line 26, file "Code")
    it is this line: var json = JSON.parse(data);

    help? I imagine there were changes and updates since this video came out?

  15. I keep getting this error: SyntaxError: Unexpected token: < (line 21, file "Code")
    On line 21 is this code: var json = JSON.parse(data);

  16. I think this was a great video. Are there any other resources out there that talk about the same concept but connecting to email databases that are not as user friendly at Mailchimp? And potentially getting data back to the browser and not a google sheet? Thanks.

  17. Hi, do you by chance have the code to add a new row in google sheets with google apps script every time theres a new mailchimp subscriber in a particular list? i´ll be more than thankful if you can help with that

  18. I´m trying to include UNSUBSCRIBE, HARD/SOFT BOUNCES per campaign, but didn´t find a way. Do you know how to do that? Any hint or help is much appreciated. Thanks.

  19. Hello Guys! I keep having this error:

    [19-01-01 20:50:37:497 PST] {instance=53157668-7588-470f-891b-6041cacec20b, detail=The API key provided is linked to datacenter 'us19', type=, title=Forbidden, status=403}

    and I'm using this code :::

    var API_KEY = 'b29cd90bca701e71eef52c0c55f36f49-us19';

    var LIST_ID = '029369f00c';


    * call the Mailchimip API to get campaign data

    * This gets all campaigns in an account


    function mailchimpCampaign() {

    // URL and params for the Mailchimp API

    var root = '';

    var endpoint = 'campaigns?count=100';

    // parameters for url fetch

    var params = {

    'method': 'GET',

    'muteHttpExceptions': true,

    'headers': {

    'Authorization': 'apikey ' + API_KEY



    // call the Mailchimp API

    var response = UrlFetchApp.fetch(root+endpoint, params);

    var data = response.getContentText();

    var json = JSON.parse(data);



  20. Para aquellos que tienen el error "The API key provided is linked to datacenter " verifiquen que coincida el data center de su "api_key" con la variable "root" (la url).
    var API_KEY = 'abcdefghijklmnopkrstuvw *-us12 * ';
    var root = 'https:// *us12 *';

  21. I have a SharePoint list to log correspondence against our contacts and i was looking to create a link between MailChimp so that whenever a campaign is sent to i.e. 90 contacts, 90 correspondence records would be created within the Sharepoint list outlining the contact that the campaign was sent to, when the campaign was sent and other information, is this possible using the MailChimp API?

  22. do people here give a good feedback and comments to this video even try those codes to see if it is working?

Leave a Reply

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