Site Building

Collect Additional Information with Merge Fields for Drupal 7

This page is archived

We're keeping this page up as a courtesy to folks who may need to refer to old instructions. We don't plan to update this page.

Sprout Video

MailChimp allows us to collect additional information about contacts that are subscribed to a list. Similar to Drupal's Field UI you can add any number of new data points, called merge fields, to a contact in MailChimp. In this lesson we'll look at how to configure merge fields in the MailChimp UI, and then demonstrate how to synchronize the value of a field in Drupal with the MailChimp merge field. This will allow us to create first and last name fields in Drupal that keep the contacts information up to date in MailChimp.

Then, we'll install the date and Token modules, and add a Birthday field to our Drupal user entities. This will allow us to look at some of the more complex configuration options available when merging field values in MailChimp. By checking the advanced option on the form for configuring the mapping of Drupal field values to MailChimp merge fields we can allow users to use Drupal 7 tokens. This opens up all kinds of new options for massaging the data within Drupal a little before sending it to MailChimp so that we can match the format that MailChimp's API expects the data to be in.

For example, we’ll use tokens to customize the format of a Drupal date field, which stores its value in the database using ISO Date format, so that it matches the MM/DD format that MailChimp expects, using a token like the following: [user:field-birthday-iso:custom:m]/[user:field-birthday-iso:custom:d]

If you're using the advanced field mapping form I highly recommend that you also install the Token module. The MailChimp module provides integration with the Token module’s UI for browsing the list of available tokens, making it much easier to create complex mapping patterns.

By the end of this tutorial you should be able to add additional merge fields to a MailChimp list and keep the content of those fields in sync with fields from a Drupal user account.

Further your learning

  • What is the use case for merge fields?
  • List the three merge fields that are added to every MailChimp list by default? Which of these is required, and why?
  • When you are configuring the mapping between a Drupal field and a MailChimp merge field using the select list interface the list is populated with a variety of options. Where do these options come from, and what do they represent?
  • Further exploration: Can you setup Drupal to collect a users address/location and then merge that data into MailChimp using a MailChimp address merge field?

Series Sponsored by MailChimp

Additional resources