Webform for Campaign Monitor

Webform is an amazing module. Thankfully, you can extend it to make it even more helpful. We’ve had a lot of clients that offer a “Join Our Mailing List” type of functionality on their sites. These forms are typically one or two fields (email and name, usually) and are for anonymous users. We use Campaign Monitor for most clients.

There is a Campaign Monitor module, but I prefer the following method, for various reasons.

Basically, just create a Webform with the same fields as defined on the Campaign Monitor side. Then, you’ll use hook_form_alter() to add a submission handler to the form. Then, you’ll just process the fields and send the values off to Campaign Monitor. Note that if you can skip saving the Webform results (normal behavior) by making your submission handler happen first. I usually choose to store the form submissions locally as well as in Campaign Monitor.

One last note: Don’t try setting the field “key” values via Webform. I haven’t had good luck with this as I don’t believe hyphens are allowed (and as far as I’ve seen, all of the Campaign Monitor field names have hyphens).

This code should give you an idea of what you’re looking for…

 

Tagged with: , , ,
Posted in Development

Leave a Reply

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

*