Netsensei

Much Ado About Nothing

Mailchimp, group names and merge tags

Okay. This is a post for future reference.

Lately, I’ve been working on a Drupal project which involves Mailchimp integration. Mailchimp is an excellent service which manages all the monkeyjobs while you can send out newsletters to lists of subscribers carefree.

The service allows you to create a (or use a predefined) reusable template for your newsletter. You pass the content which needs to be send out on a frequent (weekly? monthly?) basis to your subscribers to Mailchimp and it will churn out a new newsletter based on your template.

One of the requirements of the project is that a subscriber can opt in to receive a customized newsletter based on selected interest groups. The content of the newsletter are Drupal nodes that were published since the last edition of the newsletter. Using the taxonomy module, these nodes are assigned to one or more of the twelve available interest groups.

I need to aggregate the data in Drupal into digestible content and send it in a single Mailchimp campaign. There’s a catch though: a campaign is send out to all users, not those that have opted in for interest groups x, y or z. So, how can you solve this?

Enter: smart merge tags with groups. Using Mailchimps’ smart merge tags within the newsletter content generated by Drupal, I can target specific interest groups.

Like this:

<br> *|INTERESTED:Interests:Sports and entertainment|*<br> Node Title B<br> *|END:INTERESTED|*

*|INTERESTED:Interests:Lifestyle|*<br> Node Title A<br> Node Title C<br> *|END:INTERESTED|*<br>

Depending on the interest groups a user is subscribed to, only the content relevant to him or her will be shown in the newsletter. Thus creating personalized newsletters. Pretty cool!

There are a few limitations though. Over the past two days, I’ve been sparring with the Mailchimp support desk (They’ve been great and very helpful!) about the usage of commas in group names. You could do something like this:

<br> *|INTERESTED:Interests:Sports and entertainment, lifestyle|*<br> Node Title D<br> Node Title E<br> *|END:INTERESTED|*<br>

Which will act as an OR filter showing content to people who are either subscribed to ‘Sports and entertainment’ or ‘lifestyle’. But what if your group names themselves contain commas? What if you had a group called ‘Sports, Culture and entertainment’. Well, Mailchimp will be confused and think these are two groups ‘Sports’ and ‘Culture and entertainment’. Since those are nonexistent groups, the content won’t show up at all. I’ve tried escaping the commas and putting everything between quotes: nothing works.

This is the solution provided by the Mailchimp people:

Regarding the use of commas in a group name, we would recommend removing these commas if at all possible.

We have passed this issue onto our developers for investigation. At this time we do not have an estimated time frame of when we will be able to hear back from them. However, we will continue to investigate and push a resolution as soon as one becomes available if our developers do believe this to be necessary.

At this time, removing all commas from the group names and creating an ELSE statement would be our top ideas!

Awesome!

Of course, you’re probably eager to hear about the Drupal bit of my Mailchimp adventures. Well, stay tuned. I’ve been toying with the Mailchimp API. And I like it. A lot. I’ve chalked up a few ideas. I’m going to let them stew a little bit longer until I’ve got a clear head about what is feasible.