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:

*|INTERESTED:Interests:Sports and entertainment|*
Node Title B

Node Title A
Node Title C

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:

*|INTERESTED:Interests:Sports and entertainment, lifestyle|*
Node Title D
Node Title E

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!


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.

3 replies

  • Mailchimp is tof ja, én gratis als je er niet in overdrijft. En het integreert goed in Drupal.

    Ik ben zelf ook op zoek om nieuwe content naar het geïnteresseerde deel van mijn gebruikers te sturen, maar ik vind je voorgestelde oplossing iets te complex. Dus maar wachten tot er een module voor verschijnt 🙂

  • Yep, het probleem is dat mensen kunnen geïnteresseerd zijn in groep k, j en l. Dan moet er een gepersonaliseerde newsletter worden verstuurd met enkel content gerelateerd aan k, j en l. Door dat er 12 groepen krijg je 12^12 mogelijke combinaties. Dat los je niet op door met Mailchimps’ segmentation aan de slag te gaan.

  • Hey Matthias,

    de mailchimp module is mooi en werkt prima. Wat ik zoek is simpel: de mogelijkheid om vanuit Drupal een nieuwsbrief te versturen (als node), net als met Simplenews. Maar dan dus de content te versturen naar Mailchimp zodat zij voor de verzending zorgen.

    Jouw oplossing doet dit volgens mij, en nog veel meer. Wil je de code delen? Ik wil voorkomen dat gebruikers eerst naar moeten gaan om een nieuwsbrief te versturen.

Commentaar is gesloten