Child pages
  • Configuring Mailchimp integration in Jethro
Skip to end of metadata
Go to start of metadata

Introduction

Our church uses http://www.mailchimp.com for mailouts, and Jethro as a church management system for tracking people. 

Jethro provides a script which allows you to manage your mailout email lists in Jethro, and periodically sync the email lists with MailChimp to keep MailChimp up-to-date. This page describes how to set this up.

Find the Jethro report ID

In Jethro, create a report (Under 'Persons') that returns the set of users you wish to sync with MailChimp. In this example we have a report called 'Coast Card':

  • In the URL, note the queryid parameter value (here 186). If you have a pre-existing report, the ID can be seen in the list of reports:

    This ID will be used later.

Set up MailChimp API Key

  • In MailChimp, click on your username, then Account Settings. In the Extras drop-down menu click API keys:

  • In the Your API Keys section, Create A Key to generate a key:

Find the MailChimp list ID

  • Create a List in MailChimp if you haven't yet done so. Eg:
  • In the Lists section, select the list you wish to populate with emails. Click Settings, then List name & defaults:
     
  • Note the List ID for later use.

Running mailchimp.php

 

 PHP errors on Debian?

You may find (on Debian anyway) that php dies with an error:

root@coastserver:/srv/www/coastec.net.au/jethro# php mailchimp_sync.php 
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525/suhosin.so' - /usr/lib/php5/20100525/suhosin.so: cannot open shared object file: No such file or directory in Unknown on line 0
Could not open input file: mailchimp_sync.php

At google's suggestion, I fixed this by purging the package:

aptitude purge php5-suhosin
  • Export the variables you found above, and run the scripts/mailchimp_sync.php script. For example:
     
$ export REPORT_ID=186    # The Jethro report ID
$ export API_KEY=......   # MailChimp API key
$ export LIST_ID=d399085675  # MailChimp List ID
$ php scripts/mailchimp_sync.php $REPORT_ID $API_KEY $LIST_ID
PHP Fatal error:  Your mailchimp list is missing the merge vars STATUS, CONG, AGEBRACKET, GENDER.  Set these up in Mailchimp then try again. in /srv/www/coastec.net.au/jethro/scripts/mailchimp_sync.php on line 76
Fatal error: Your mailchimp list is missing the merge vars STATUS, CONG, AGEBRACKET, GENDER.  Set these up in Mailchimp then try again. in /srv/www/coastec.net.au/jethro/scripts/mailchimp_sync.php on line 76

Initially you will get the errors above.

To fix this, go to your MailChimp List's Settings -> List Fields page:

  • Click Add A Field and define a field for each one that the mailchimp_sync.php complained about:
     
    Click Save when you're done.
  • Now run the script again. It should complete without errors or any output:

    $ php scripts/mailchimp_sync.php $REPORT_ID $API_KEY $LIST_ID
  • In MailChimp, your list should now be populated with subscribers. Click Manage Subscribers -> View subscribers to see them:
  • Finally, automate periodic running of the sync script by creating a file, /etc/cron.d/mailchimp:

    API_KEY=.....
    # 186 = Coast Card
    */10 * * * * root php /srv/www/coastec.net.au/jethro/scripts/mailchimp_sync.php 186 ${API_KEY} 1fab01b311

 

 

  • No labels