Mailchimp + Magento: How to get autoresponders working with the API

February 1, 2010

Just a quick little how-to on Mailchimp and Magento using the existing extension by Ebizmarts. We want to be able to send customers who sign up for the newsletter through the Magento store a little thank you gift (discount code) X days after signing up using Mailchimp’s excellent autoresponders. This is supported by Mailchimp, but requires double opt-in or the following little 2 step work-around with the Mailchimp API.

For this I’ll assume you have got as far as the Mailchimp list being populated when a Magento customer subscribes, and removed when they unsubscribe. This will require a little modification to the Magento and Mailchimp integration, so only proceed if you’re comfortable with that.

Step 1: Configure your Mailchimp list to have a pseudo sign up date

This is mentioned in the Mailchimp support section, but I’ll quickly add my notes here for completeness.

Go into the lists section and select the forms link for the particular list you are adding emails to from within Magento. From the forms page you can add a new date field that looks something like this:

Field Settings for a new sign on date field

Field Settings for a new sign on date field

Note that whatever you choose for the field tag e.g. SIGNON on this screen needs to match what you use in the code change I’ll show you in step 2. What a perfect segue….

Step 2: Modify the Mailchimp extension (ever so slightly)

The code change is very minor, and assumes you always want to add this Merge var – so it’s not very elegant. In fact it’s arguably a hack, but I haven’t posted one of those for a while so here goes. Modify the file app/code/local/Ebizmarts/Mailchimp/Model/Mailchimp/Mailchimp.php around line 114 so that it looks like this:

if ( $this->getXMLSubscribeConfig('opt-in') != '' ) {
	$merge_vars['OPTINIP'] = $this->getXMLSubscribeConfig('opt-in');
}
// Add this line - be sure you match 'SIGNON' here with the code you chose in Mailchimp...
$merge_vars['SIGNON'] = date("Y-m-d"); // today's date
try {
	$apikey = $this->getXMLGeneralConfig('apikey');

Right so with that change, your Mailchimp list will now get a new variable populated which can in turn be used as a date for the autoresponders within Mailchimp like so:

Set the autoresponder to use the new date you added in Step 1.

Set the autoresponder to use the new date you added in Step 1.

Interestingly this same approach can be used to add all sorts of useful information gained from Magento into your Mailchimp list e.g. Source of visit CPC/Organic etc.

Note: this code change will go away if you upgrade the Mailchimp extension – maybe someone will make this part of the extension so that it is less prone to being hosed by upgrades. Until then, beware.

Ashley

Posts

Hi! I'm Ashley Schroder, a Software Engineer from New Zealand - this is a collection of notes on my experiences with Ecommerce Web Development, particularly Magento Development.

Are Your Customers Getting The Magento Emails You Send?

MageSend Magento Email sending with Amazon SES

I have made a premium Magento Extension called MageSend. MageSend makes it simple and easy to send using Amazon's highly reliable SES email service.

The extension is $99, and comes with a complete money back guarantee, please check it out, I am confident it will resolve any email sending problems with your Magento store.

10 responses to Mailchimp + Magento: How to get autoresponders working with the API

  1. I have been using campaign monitor….got it working but it seems a bit limited…have not tried it yet with 1.4…mainly i am using it because its pay per use…is MChimp way way better?

  2. Tough call on the Campaign monitor vs Mailchimp. I think there is a pay-per-use account for Mailchimp too – I haven’t used Campaign monitor, but do recommend Mailchimp to people. We use it for email marketing for several of the suppliers we represent in the US and have no complaints about the reliability or reporting they offer.(they should send me a t-shirt shouldn’t they…).

    I will be adding more autoresponder support for Magento in the future, particularly around soliciting product reviews/order feedback from customers 1-2 weeks after the order ships. Does Campaign monitor offer anything like that?

  3. That feature would be great. Soliciting a feedback from customers after 1-2 weeks would be a cool feature.

    Looking forward to find out more about it 🙂

    Regards and keep the good work.

  4. Hey Ashley,

    used your hint here and extended the extension to add a config param to insert the field tag. While at it, I also added the ability to select a grouping that the subscriber should be put into if a groups have been created for the list.

    Good if you want to segment subscribers that use a join form on the store or blog…

  5. Ashley,

    Great blog you have here, I’m using you’re smtp pro extension and when looking for a Magento Mailchimp Autoresponder issue I ended up here again 🙂 I have the autoresponder working thanks to your little hack! So thanks a lot.

    I was just wondering how you solved the issue that when a user UNsubscribes in Mailchimp it still subscribed in Magento, do you have a script that handles this via the Webhook? Love to hear your thoughts on this. Best Regards from Spain!

  6. Thanks Sebastian, I don’t have a really good solution for that, other than the list in Magento is sort of arbitrary in the scheme of things. The mailchimp solution makes the list Magento keeps internally redundant – I don’t use it for anything once mailchimp is hooked up.

  7. Hi Ashley,

    Whoa! Love the new Comment View as I type this!

    Curious, did you ever create the order auto responders for soliciting product reviews and feedback X days after an order? Surprisingly, I haven’t found anything like that for Magento yet. Still looking…

    Joe

  8. @Joe Fletcher Hi Joe, I did create the autoresponders. I wrote up a bit post about them actually over here: http://www.world-wide-access.com/2010/11/24/a-case-study-in-automated-post-sale-ecommerce-customer-communication/

    We have kept the functionality in-house for the time being, but I’m always open to the idea of releasing it.

    Also, thanks for the feedback on the comments. I’m not sold on it personally – but I don’t have time to rework it just at the moment.

  9. @Ashley Very cool you got that set up and looks like the results were just what you wanted.

    If you decide to release it, I’d consider setting it up. I have a client who’s thinking about doing this now, but I’m sure others can & would use this.

  10. Hi there,

    We have recently released a free full featured MailChimp extension for Magento.
    It supports sending additional fields as merge fields, ECommerce360 integration, multiple lists and interests groups, bulk sync, etc…

    You can find it here http://www.magentocommerce.com/magento-connect/ebizmarts/extension/1208/ebizmarts-mail-chimp-module

    Enjoy it, Eep, Eep!