Jojodae Ganesh Sivaji
March 5, 2012
MailChimp is a Web service offering platform for e-mail marketing. It is easy to start, use and scale. In short, we can design, send, and track HTML email campaigns/newsletters with simple tools. There are lot of things that makes us feel that MailChimp is the right choice for our needs. The list goes on with API to sync from inhouse sites/ applications, intuitive reports, integration with existing services like Facebook, Twitter, and Google analytics, ability to create custom forms, etc. Of course we like MailChimp's humor as well.
[[{"type":"media","view_mode":"media_original","fid":"98","attributes":{"alt":"","class":"media-image","style":"box-shadow:0 0 0 rgba(0,0,0,0);","typeof":"foaf:Image"}}]]
At KnackForge we often use MailChimp for our client's project and the demand for creating different type of campaigns has been always felt. In this post, I would like to share one of the tricks we implemented in a recent client project. As the title say it's about programmatically creating a campaign from view output in Drupal 7.
'. print_r($result, 1) . '
'
));
Above is the code that we have been using in one of our production sites. It assumes that the MailChimp module has been installed on your Drupal site. Configured with API key to communicate with mailchimp.com and also expects to have a list created from Drupal admin interface. Though this can be used as such without much modification except a few like cron key, MailChimp list id, machine name of view, etc. code has been modified for blog post typos/ bugs expected :-)
The usecase we had to address was little tricky i.e. to send active deals in given location based on user's profile field value. We achieved it by having a single generic list in Drupal site and syncing remote lists using hook_user_presave(). This may not be clear at first read. The gist is, to keep the code simple we have changed it as above. I hope this would help to get started.
Just like how your fellow techies do.
We'd love to talk about how we can work together
Take control of your AWS cloud costs that enables you to grow!