I wrote a module for a site I maintain to allow creation of a new Mailchimp campaign from a given node. The module extends the node creation form and adds a checkbox for "Create campaign in Mailchimp".

The module currently does not provide any administrative interface, and to be useful to others, you would have to go through the code and enter information particular to your setup.

Would this be helpful to anyone?

Comments

nicksanta’s picture

Title: Create a campaign from a node » Create a campaign from within Drupal

I'm scoping a project for a client who has ambitions to be sending 10,000 newsletter emails per-day with the site's latest content. In my opinion having an ability to create new campaigns (whether they be nodes, views etc..) from within Drupal would be absolutely awesome.

So I definitely think putting your code up as a tarball would be a great start for anyone who would want to tackle this (possibly me even). If the clients go ahead with the project, they are keen to have as much code contributed as possible.

kostajh’s picture

StatusFileSize
new2.78 KB

Attached is a very crude implementation of a Mailchimp Campaign module. The module allows your to extend the node creation form for a given content type and adds a checkbox to "Create a campaign in Mailchimp". Upon saving the new or existing node, a new campaign is created in Mailchimp, and the user is presented with a link to review the new campaign in the Mailchimp web interface. The module depends on the Mailchimp module.

Please note there is no administrative interface; if you wish to use this you will have to edit the .module file to specify the components specific to your use case. You will also have to use some functions (documented in the code) to find out the list_id and template_id for your setup.

The MCAPI.class.php file is really well documented and should provide you with guidance if you get stuck.

nicksanta’s picture

The project I was scoping this for has just been green-lit. Is there support from the mailchimp module maintainers to have this feature as a plugin module shipped with mailchimp.module?

Here is a bit of a breakdown on how I thought the best way to tackle it would be. I'll assume the imaginary user is creating this campaign manually.

  1. User specifies a drupal internal path and theme that should be turned into a campaign (lets use 'node' as an example, but this system means that a view, node page or anything could work)
  2. Creating the campaign causes the module to make a http request to the specified URL, but with a query parameter which forces the theme they selected to be loaded
  3. A php script runs over the resulting document, and converts all stylesheets to inline styles.
  4. Result is displayed to user for confirmation
  5. On confirmation the campaign is created in mailchimp.

I'm thinking that selecting a theme for the campaign would be ideal, because we can ship a default one along with this module, and the user could also develop their own theme that is optimised for email clients.

If anyone has any suggestions, I would love to hear them.

nicksanta’s picture

by the way @kostajh, I've reviewed your code and it's very clear and well documented. Thanks for putting it up!

nicksanta’s picture

Assigned: Unassigned » nicksanta
StatusFileSize
new7.12 KB

It looks as though the mailchimp module maintainers aren't browsing the queue all that often, so it may be difficult to involve them in the development of this feature. Unfortunately this probably means it will get rejected for inclusion in the mailchimp package.

Progress so far:
Mailchimp Campaign module provides a node type 'mailchimp_campaign' which stores all pertinent information for creating campaigns, and settings for sending. I decided to go the node type route (similar to simplenews) mainly because of the infrastructure the node module provides out of the box, which makes customizing things much easier from a developer's perspective.

When filling out the node form, users specify some settings (this will need work from a UX perspective), an internal path to get the HTML, and a theme to use when getting the HTML. At the moment, we're simply passing the URL to mailchimp who look after parsing the result and converting css to inline styles etc...

After saving the node and when viewing it, those with relevant permissions can 'Create' the campaign, or 'Create and Send Immediately'.

There are alot of bugs as I've only been working on it for just under a day, but i'll incrementally upload development snapshots so people can have a look and give some feedback.

nwe_44’s picture

I'd be very interested in these developments. If I can help in any way I will. Of related interest to me would be the addition of groups as mail merge options.

nicksanta’s picture

StatusFileSize
new12.68 KB

@nwe_44 I'm trying to keep it as 'low-tech' for the moment, and let other modules do tricky / edge-case stuff.

I haven't had time to do much work on this during the last month, but back into it now. I've added a submodule which allows recurring / scheduled campaign sending. At the moment, it all kinda works, but not really. Don't try using it with actual subscriber lists.

I'm putting this code up for anyone who is interested in checking it out, but as it stands this is ABSOLUTELY NOT ready for production sites. Once it is I will either try and get this packaged with the MailChimp project, or create a new project.

levelos’s picture

Sorry for not chiming in sooner, I'm the module developer / maintainer. I've been following the thread and there's some great work here. I am a bit hesitant, though, about including it in the module as I just don't think a node is the right paradigm from which to create an HTML email. MailChimp has a team of developers working really hard to build a top notch UX for creating the campaign emails, and to ensure they display correctly in all the various email clients. I don't think we'll be able to recreate this success easily from within Drupal.

There's also a related, alternate approach that I'm working on with another developer that will import your already created MC campaigns into Drupal as nodes. A bit of a reverse approach, but one that's safer and still syncs your campaigns with nodes. This will likely become part of the module package.

Of course you can always create your own project with a dependency on this one; I'll be happy to help in any way I can.

nicksanta’s picture

@loubabe, at the moment nodes are only used to store settings required to create campaigns. The mailchimp interface is awesome for creating single campaigns (which would probably apply to the vast majority of users). The crux of what I'm trying to achieve is creating highly customized HTML campaigns, which can be scheduled to send at regular intervals. If you install the module and create a campaign, you'll notice there is no "content" field. You will notice the "url" field though, which allows you to specify an internal url to use.

Case in point:
Our client needs a solution which can send 3 daily campaigns to 10,000+ subscribers. The campaigns include latest content on the website plus various ad units. They want a featured article at the top, and the rest of the content grouped by taxonomy terms with the term title above them. Those relatively complex design features ruled out an RSS campaign.

So, using this module you simply create a recurring campaign that points to the required URL (in this case, a panels page to organise the layout) and let cron handle creating and sending the campaign.

This is the third project I've been involved in that has had requirements similar to this in the last 12 months. The past 2 we've used a custom solution, which was a PITA to maintain. I just thought it was time to move on and create a solution that is going to work and scale.

Although, I've just convinced myself that this module probably doesn't belong in the mailchimp project proper. It is quite a niche requirement.

levelos’s picture

Thanks for the follow up @nicksanta, that clarified it a bit. But I agree that it probably makes the most sense as a standalone. If you want to integrate and/or create a dependency on Mailchimp, I'd be happy to make that work and support it. Lets close out the issue or move it to the new module when you're ready.

kostajh’s picture

@nicksanta, if you move to create this as a new project, let me know as I might have some time to help.

nicksanta’s picture

Title: Create a campaign from within Drupal » Feature discussion
Project: Mailchimp » Mailchimp Campaign
Version: 6.x-2.x-dev »

@loubabe - moved to the mailchimp campaign issue queue. I appreciate your offer of help, at the moment I can't see anything that needs to be done on your end, but I will let you know if there is. :)

@kostajh - cool, have you got any particular goals regarding the module? At the moment I'm not averse to a rewrite. I used the node architecture to quickly knock up a prototype, but I can see reasons for it not being the best option. And without discussion with other developers it's easy to make something that only works for your own use case!

geomark’s picture

Component: Code » Miscellaneous
Assigned: nicksanta » Unassigned
Priority: Normal » Minor

This sounds like it would solve an issue I encountered. Mailchimp is great, but I wanted newsletters to be archived on my site, not on Mailchimp domain. After all, I put a lot of effort into great copy only to have it add value to Mailchimp's domain instead of my own.

I solved my issue by creating a new content type "Newsletter" which has a feed. So now I create the newsletter on my Drupal site, Mailchimp imports the feed and blasts the email. It works fine, but it is not so elegant as being able to create and manage a campaign all within my Drupal site.

I am not a coder so can't really contribute other than to offer encouragement.

BenK’s picture

I'm interested in Mailchimp Campaign, but what I really need is the ability to create a Mailchimp list or interest group from within a Drupal site. For instance, I'd love to be able to use the Views Bulk Operations module (http://drupal.org/project/views_bulk_operations) to select specific Drupal site users for a Mailchimp list (or interest group).

This way, an administrator could send a campaign to a specific list of users based on criteria that isn't necessarily contained within Mailchimp data fields. (For instance, you could send an Campaign to all users of a given role who have logged in within the past 30 days.)

Any interest in this type of list creation functionality?

nicksanta’s picture

@geomark:
I'm not really designing this as a solution to replace MailChimp's own single campaign tool. It won't archive the actual generated campaign content, and I dont think there is a need to - Mailchimp already store all campaign created, whether through their interface or the APIs.

@benk:
This module isn't going to handle subscriber lists. One option for what you want is to use Views Bonus Pack to export a view of users to CSV, and then import into Mailchimp manually.

geomark’s picture

@nicksanta, understand. Just to make clear what I meant, it's the MailChimp archiving that I want to avoid, the point being I want content archived on my site, not theirs.

bitkid’s picture

Hi guys

I have the same need as geomark. I need a module that generates nodes of type newsletter and tells MailChimp to use that as a campaign.
That way I can always show my old newsletters to users on my own site and the admin can see exactly what the newsletter is going to look like before sending it.

Has this module been updated since May? The project page says May 28th and there is no code attached. Only code is on this page and is dated May 24th.

denes.szabo’s picture

Hi,

I would like to ask, how going this module? I need to collect news from a site then send out daily, weekly newsletter. This module would be perfect - I should fill the campaign node automatically, then send as a newsletter.

How can I help? Are there any plan for this module? Where should I start?

ss81’s picture

Version: » 6.x-1.x-dev

Hi,

I'm interesting in this module too. Any news about it? Could I help in development? Is there a version for D7?

tanc’s picture

Status: Active » Fixed

Hello there. This module has just resurfaced under new ownership (mine) and is being used on two production sites I manage. I have just been on holiday so haven't had time to tidy up the code for release but it should be there in the git repo if anyone wants to grab it.

I'll put together a dev release shortly and we'll take it from there. D7 version will be worked on once D6 version has a stable or at least a beta release.

I'm going to close this issue as its its time now to test the code, put individual feature requests in the issue queue and submit bug reports and patches.

ss81’s picture

Hello tanc,

I would be happy to help you in work on D7 version because I may need to realize this feature soon for D7.

tanc’s picture

Ok excellent! Lets open a new issue for D7 then and get to work! I'll create a branch for it in the git repo.

levelos’s picture

Hey guys - Just seeing this and wanted to give a heads up re: the new architecture and direction for the mailchimp module for D7. Check out the project page and this recent post about the changes, http://thinkshout.com/blog/2011/06/lev/mailchimp-20-anatomy-drupal-modul....

tanc’s picture

Hi Levelos, I did see your post and am greatly looking forward to seeing that take shape. Meanwhile this module may fill the gap for D6 at least.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.