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.
This series introduces you to the MailChimp email marketing service and the various ways it can be integrated with Drupal via the MailChimp module. Learn how to create and manage mailing lists, design email templates, and send effective email marketing campaigns with Drupal and MailChimp.
This series is about integrating MailChimp with Drupal 7 using the Drupal MailChimp module. It will help site builders and content creators create awesome email marketing campaigns and grow the number of subscribers on their mailing lists.
Email marketing is a proven way of increasing the traffic to your website. Even better, it’s a great opportunity to engage with your site's visitors, your store's customers, or your application's users, and learn more about them. When it comes to email marketing, MailChimp is one of the best tools for managing emails lists and analyzing email data. Lucky for us, the Drupal MailChimp module makes integrating MailChimp and a Drupal powered application easy.
In this series we'll cover:
- What is MailChimp?
- Installing and enabling the Drupal MailChimp module and its requirements
- Creating, managing, and soliciting subscribers to mailling lists in MailChimp and Drupal
- Keeping MailChimp data in sync with a Drupal user's profile
- Sending email campaigns in both Drupal and MailChimp
- Email marketing best practices
- Monitoring activity with MailChimp
And a lot more!
Our case study is the Anytown Ice Cream shop, which has three physical stores, and a website that provides its customers with info about the stores. We’ll create a mailing list for semi-regular updates, similar to a newsletter, and another that allows people to receive flavor of the day updates, optionally targeted to the stores they've listed on their profile. To keep things easier for our employees, we’ll automate the process of sending the flavor of the day emails using an RSS-based campaign. We’ll also look at collecting a customer's birthday so we can send them specials. I’ll refer back to this case-study a few times or use it to explain concepts.
Before you dive into this series, there are a couple of things you’ll want to know how to do first. I'm going to assume that you've already got some basic Drupal administration knowledge, notably how to download and install a module, and are at least familiar with Drupal’s UI for adding and editing fields as we’ll be using it a lot without going into details about the non MailChimp-specific parts. If you need to brush up take a look at our Drupal 7 site building guide for a refresher.
Finally, if you want to take your learning further look for the follow up questions in the description for each tutorial in this series. These questions are presented to help you make sure you’re understanding the material, and to encourage you to explore how what you've just learned could apply to your own use case.
Ready to learn how to integrate MailChimp and Drupal so you can create an awesome email campaign? Then you're going to love this series.
Drupal can already send email, and there are plenty of contributed modules that allow you to maintain a mailing list within Drupal. But there are some distinct advantages to using a service like MailChimp to maintain your mailing list and send your emails. In this tutorial we’ll talk about what MailChimp is, look at the benefits of using MailChimp with Drupal, cover some terminology that you'll want to be familiar with, and take a really high level look at how the MailChimp module goes about accomplishing its integration.
What is MailChimp? MailChimp is a web based service for designing and sending email marketing campaigns, and maintaining one or more lists of subscribers.
Why should you choose MailChimp? There are a lot of reasons to choose MailChimp as the tool to use for managing your email marketing efforts. At a really high-level it boils down to the fact that a service like MailChimp, which has an entire team dedicated to improving it's application, can potentially create tools and manage infrastructure that would be hard for you to develop on your own. In addition, MailChimp has a strong track record, and great integration with Drupal via the MailChimp Drupal module.
The MailChimp Drupal module allows you to tightly integrate your Drupal site with the MailChimp service by leveraging the MailChimp API. You can allow users to subscribe to your mailing lists, and manage their subscriptions, from within Drupal. Values collected for a field attached to a Drupal entity can be synchronized with merge fields for contacts in a MailChimp list. Administrators can send email campaigns right from within the Drupal UI, and monitor their performance. And much more.
By the end of this tutorial, you should be able to explain to someone why they might want to use MailChimp with Drupal. You should also be able to list the various types of integration provided by the MailChimp module.
Take your learning further
- In one paragraph answer the question: What is MailChimp?
- List the modules contained within the MailChimp project on Drupal.org.
- Describe two ways that MailChimp helps prevent you from being flagged as a Spammer.
- How does MailChimp aid content creators who are trying to create and send email campaigns?
- Further exploration: Can you generate a pros/cons list to use when deciding wether or not you should use MailChimp for your project?
In order to integrate Drupal 7 with MailChimp we need to first install the MailChimp module, and its dependencies. This will provide the framework that we'll use for our integrations throughout the rest of this series. The MailChimp module depends on the Entity API module, the Libraries module, and the MailChimp PHP API Client, so we'll need to install these as well.
The MailChimp project on Drupal.org consists of the main MailChimp module (mailchimp.module) that provides API integration, and a handful of sub-modules that use this API integration to allow Drupal to interact with various aspects of MailChimp. These are:
- mailchimp_signup: Create anonymous signup forms for your Mailchimp Lists, and display them as blocks or as standalone pages. Provide multiple-list subscription from a single form, include merge variables as desired, and optionally include Interest Group selection.
- mailchimp_lists: Subscribe any entity with an email address to MailChimp lists by creating a mailchimp_list field, and allow anyone who can edit such an entity to subscribe, unsubscribe, and update member information. Also allows other entity fields to be synced to Mailchimp list Merge Fields. Add a Mailchimp Subscription field to your User bundle to allow Users to control their own subscriptions and subscribe during registration.
- mailchimp_campaigns: Create and send campaigns directly from Drupal, or just create them and use the Mailchimp UI to send them. Embed content from your Drupal site by dropping in any Entity with a title and a View Mode configured into any area of your email template.
- mailchimp_activity: Display a tab on any entity with an email address showing the email, subscribe, and unsubscribe history for that email address on your Mailchimp account.
By the end of this tutorial you should be able to install the MailChimp module and all it's required dependencies and libraries, and confirm that they are all working.
Further your learning
- List the other non-core modules that are required in order to use the MailChimp module.
- What version of the MailChimp PHP API client does the MailChimp Drupal module use?
- The MailChimp project contains multiple sub-modules. What role does the MailChimp Campaigns sub-module fulfill?
- Explore further: What other projects on drupal.org that are not part of this series aid with integrating MailChimp with Drupal? When might you use one of those instead?
Before you can do anything else with MailChimp you'll need to create a MailChimp account. In this tutorial we'll walk through creating an account on MailChimp.com. Then, we'll look at where to find your API key, and how to add it to Drupal so that the Drupal MailChimp module can communicate with MailChimp on your behalf. Adding your API key is a required step to get MailChimp integration working with Drupal. Without an API key, Drupal can't make requests to MailChimp on your behalf.
By the end of this lesson you should have an account on MailChimp.com. You should also have located your account's API key and configured Drupal to use it.
Further your learning
- Why does MailChimp require personal details like address and phone number when creating an account?
- What is the purpose of providing Drupal with a MailChimp API key?
- Further exploration: In theory you can share a single MailChimp API key between multiple different Drupal sites. What effect would this have on your integration?
Mailing lists are the heart of all things MailChimp. Lists allow us to gather a database of email address, and other additional information, by asking people to subscribe to our list or by doing so automatically based on other actions they take within our application. Once subscribed, and added to a list, these addresses can be sent emails. MailChimp lists allow users to manage their own subscriptions, and to easily opt-out as desired.
In this tutorial we'll look at creating our first list in the MailChimp UI. We'll create one for a weekly newsletter on our site. And then we'll install the MailChimp Signup module and use it to create a simple form that allows users to subscribe to our mailing list.
The MailChimp Signup module can be used to create a page with a sign up form on it by specifying the internal path for the new page and choosing which list, or lists, the sign up form should allow a user to subscribe to. In addition, you can also create a sign up form as a block. These blocks are then available to place into any region on your site via the Drupal block administration screen. This gives you a lot of flexibility when it comes to placing sign up forms. Learn more about placing blocks on your site in the Working with Blocks in Drupal 7 video lesson.
Sign up forms created using the MailChimp Signup module will work equally well for anonymous and authenticated traffic. These are a great substitute for the copy/paste HTML forms that MailChimp gives you, with some distinct advantages, like for example keeping the labels of fields up to date if they change in MailChimp without having the copy/paste a new version of the HTML form.
By the end of this tutorial you should be able to create a MailChimp list and allow people to subscribe to that list via your Drupal site.
Further your learning
- When you create a list in MailChimp you provide some default configuration for that list. Where do you change those default settings?
- Which of the MailChimp project's sub-modules are required to be able to create a form that will allow visitors to subscribe to a MailChimp list? (Hint: there are 2 of them).
- What are the display modes available for a signup form created in Drupal? How do they differ?
- Further exploration: Can you add an “Interest group" to your MailChimp list and then have it displayed on the subscription form in Drupal?
One of the main advantages of using the MailChimp module to integrate Drupal with MailChimp is that you can allow users of your site with a Drupal account to manage their MailChimp subscriptions right through the Drupal user interface. In this tutorial we'll look at adding a MailChimp Lists field to Drupal's user entity type and then configuring that field so that we can allow users to subscribe/unsubscribe from a MailChimp list by signing in to their account. We'll also look at how we can allow users to opt-in to a MailChimp list when they register for a new account on our Drupal site.
The MailChimp Lists module is super flexible, and allows you to create a relationship between any fieldable Drupal entity and a list in MailChimp. While we're going to be using the module exclusively with user entities there are a lot of other options available. Basically, any entity with an email address can be subscribed to a list by adding the MailChimp Lists field to the entity type, choosing the list that subscriptions should be added to, and telling the field which other property, or field, on entities of this type contains a valid email address.
By the end of this tutorial you should be able to configure your Drupal site to allow users to manage their MailChimp subscription from within Drupal. As well as allow new users to opt-in to your mailing lists when they sign up for an account.
Further your learning
- Why does the MailChimp Lists module use a Drupal field API field to track subscriptions?
- Can you describe the primary difference(s) between allowing users to subscribe via the MailChimp Lists module, and allowing users to subscribe via the MailChimp signup module?
- Further exploration: What happens if you delete the account of a user who is subscribed to a MailChimp list?
- Further exploration: Can you create a new node type that can be subscribed to a MailChimp List? Give a use case for doing so.
- MailChimp Lists module documentation (drupal.org)
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:
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?
Before you start sending email newsletters to your mailing list, it's a good idea to have a plan, set some goals, and understand what you're trying to accomplish. In this tutorial, you'll get a quick primer on email marketing and the things you can do to ensure your campaigns are successful.
I’m not an email marketing expert by any stretch of the imagination. But there are lots of suggestions in here that will help you further your own research into creating successful campaigns, as well as some good ideas about where to start. If you’ve never planned an email marketing campaign, then this tutorial is for you. If you’re an experienced veteran, there may be some good refreshers in here. You can also skip ahead to the next tutorial and start sending emails.
Further your learning
- List three things you should do as part of the copy editing/review process every time you send a campaign.
- What are some things you can do to prevent your emails from being labeled as SPAM?
- Further exploration: Write a draft set of guidelines for you or your team to follow when preparing to send a new email marketing campaign.
There are two ways you can send an email to a MailChimp list: through the MailChimp UI, or via Drupal. In this tutorial we'll look at using the MailChimp UI to send an email campaign to our mailing list. We'll also use MailChimp to segment an existing mailing list into smaller, more targeted, groups to send a campaign to, allowing us to be more effective with targeting those users on our list that we know will care about a specific announcement.
The MailChimp UI for composing and sending an email campaign is awesome, and has some great tools for content creators. In this tutorial we'll choose a a template, draft a newsletter, send a test email, and then finally send the real thing.
After that, we'll look at how we can use the values of the merge fields associated with subscribers in our list to segment the list and send a campaign to just the people in a specific location. Or example use case is that our hypothetical ice cream store has physical locations in Aspen, Carbondale, and Glenwood Springs. When a user signs up for our mailing list they can optionally let us know which store, or stores, they frequent. Then, when our Aspen store has its two year anniversary, and we're going to offer specials at just that store for the weekend, we can email our list and let them know. Rather than spam the entire list, we can target just those people who have identified that they frequent the Aspen location. Pretty cool.
By the end of this tutorial you should be able to send a new email campaign from within MailChimp to your list of subscribers, as well as know how to leverage list segmentation.
Further your learning
- Can you give two example use cases for list segmentation?
- What are the different ways that you can preview an email campaign in the MailChimp?
- What are merge tags in MailChimp?
- Further exploration: Explore the various templates and themes provided by MailChimp. Are there any that would serve as a good starting point for your email campaigns?
In an earlier tutorial, we looked at sending emails from the MailChimp UI. Now let's look at sending a campaign to our MailChimp list via Drupal. In this tutorial, we'll enable the MailChimp Campaigns module, and send a campaign through the Drupal UI. We'll also talk about the various advantages and disadvantages of doing it this way vs. via the MailChimp UI. The big win is that your site's administrators don't have to know anything about MailChimp, instead they can just do all their work right in Drupal. There is also the ability to use a token-like syntax to include the content of existing nodes on your Drupal site rather than copy/pasting their content into MailChimp.
By the end of this tutorial, you should be able to send a MailChimp email campaign via Drupal, and understand the advantages and disadvantages of this approach in order to help you decide which method is best for you.
Further your learning
- What additional permission(s) does the MailChimp campaign module add, and what do they allow?
- What are the two primary advantages to sending email campaigns through the Drupal UI?
- Explain the use case for the MailChimp text format. What does it allow that other text formats do not?
- Further exploration: Can you use Views to create a list of archived/sent campaigns that is available to the public on your site?
The MailChimp Lists module provides integration with the Views Bulk Operations module. This integration allows site administrators to create a view, and then use the contents of that view to create a new segment for a list in MailChimp. This is pretty cool because there are a lot of things that Drupal knows about your users that MailChimp doesn't. So we can begin to use the powerful Views module to create list segments that might otherwise be impossible to generate.
In this tutorial we'll install the Views Bulk Operations module (VBO) and it's dependencies. Then, we'll create a view of users on our site that can be filtered based on the user's role. Finally, with the VBO integration, we can use this to create a new segment in our mailing list for just users on our site with a specific role.
By the end of this tutorial you should be able to create a new list segment in MailChimp based on the content of a view in Drupal.
Further your learning
- What does the Views Bulk Operations module do?
- Can you list three examples of list segments you could create with the information in Drupal that you couldn't create directly in MailChimp?
- Further exploration: Can you create a view that allows administrators to create a new MailChimp segment that contains only users who logged in to your site in the last month?
One of the best features of MailChimp is its awesome template creation tools, and their ability to allow anyone to create beautiful email templates. Unfortunately, the templates created in MailChimp are not supported by the Drupal MailChimp Campaign module without a little extra work. In this tutorial we'll take a look at creating a template in MailChimp using their drag and drop template creator. Then, we'll walk through the extra steps required in order to have these custom templates you create available in Drupal when using the MailChimp Campaigns module to send a campaign.
In addition to just making the templates appear in Drupal, we’ll also want to declare which regions in the template should be editable within Drupal. So we’ll use the
mc:edit="" HTML attribute in our template. Any DOM element we add this attribute to will become a section, which content creators on our Drupal site can insert content into.
By the end of this tutorial you should be able to create a custom email template in MailChimp and know how to make it show up as an option in Drupal. You should also understand how to edit your template's code to include editable regions that Drupal can display and editors can use.
Further your learning
- Why do you need to export a template to HTML and then re-import it?
- What does the custom `mc:edit` attribute do in an HTML email template?
- Further exploration: Can you create a new template that is a 2x2 grid, and make that template available to someone creating an email campaign in Drupal?
MailChimp offers the ability to set up RSS-based email campaigns that automatically send daily, weekly, or monthly emails to your subscribers based on the content of an RSS feed. In this tutorial we'll look at creating an RSS feed of ice cream flavor updates in Drupal using Views, and then configuring a campaign in MailChimp to use the content of that RSS feed to send a daily email to anyone subscribed to our Flavor of the Day list.
I'm not going to cover creating an RSS feed in Views during this tutorial. Instead I assume that you've already created the necessary feed on your own site. If you’re not familiar with creating feeds with Views check out this video tutorial, Creating Views Attachments, which demonstrates how to create an RSS feed in Views.
In order for your RSS-based campaign to work, your Drupal site needs to accessible to the web, so that when MailChimp tries to read the content of your RSS feed, it can do so. If you're just testing this out, you can use a tool like ngrok.com, or just create a dev site on Pantheon or Acquia to play with.
By the end of this tutorial you should be able to create a campaign in MailChimp that pulls data from an RSS feed in Drupal and sends an email with that data to your mailing list on a regular basis.
Further your learning
- Give an example of a use case for RSS-based campaigns that would be useful for your users.
- What do you need to do on the Drupal side of things in order to create an RSS-based campaign?
- Can you send an RSS-based campaign to a segment of a MailChimp list?
- Can you test an RSS-based campaign with a Drupal site on your localhost?
- Further exploration: Can you add an RSS feed to a regular campaign template? Hint: *|RSSFEEDBLOCK|*
- Creating Views Attachments, covers how to make an RSS-feed in with Views
- MailChimp documentation for creating an RSS-driven mail campaign
- MailChimp's Merge Tags for RSS-driven campaigns
- MailChimp's RSS item tags
MailChimp has the ability to trigger a webhook, or push notification, whenever someone takes an action on their MailChimp account. For example, when someone unsubscribes from your mailing list by clicking the link in their email, instead of logging in to their Drupal account and using the checkbox provided there. Drupal, can be configured to listen for these webhook notifications, and take action whenever one is received. This is particularly useful for allowing Drupal to update cached data about subscribers in real time.
If you're using MailChimp with Drupal I highly recommend configuring the webhook integration. It helps to keep the information contained in Drupal and in MailChimp in sync. And, it is super easy to do. In addition, whenever a notice is received, the MailChimp module triggers
hook_mailchimp_process_webhook(), documented in
mailchimp.api.php. This allows your custom modules to respond to someone subscribing or unsubscribing from your mailing list in any way you want.
In this short tutorial we'll look at how to enable web hooks for your lists in MailChimp, and then talk about why this is an important feature to enable.
In order for the webhook integration to work your Drupal site needs to be accessible to the internet so that it can receive HTTP posts from MailChimp's API.
By the end of this tutorial you should be able to configure Drupal to respond to MailChimp webhook notifications.
Further your learning
- Why is it important to configure the MailChimp webhooks?
- Can you give an example of an action that would cause a MailChimp webhook to be triggered?
Using the MailChimp Activity module we can allow site administrators to view activity and statistics for any Drupal account subscribed to our mailing list, or any entity for that matter. In our example we only have user accounts subscribed at the moment though.
Once enabled, and configured, the MailChimp Activity module will display a tab for each user account with details about what emails they have received and whether they have opened them or not. This is a subset of the data that MailChimp collects for us to help analyze the success of our campaigns. It's only a small portion of the data available, but it's nice to be able to see it right in Drupal. It also opens up the opportunity for content creators who have access to Drupal, but not MailChimp, to see how their email campaigns are performing.
In this tutorial we'll take a look at enabling the MailChimp Activity module, configuring it to display the information we want, and the permissions that it provides to determine who is allowed to view these statistics on your Drupal site.
By the end of this lesson you should be able to navigate to the "MailChimp Activity" tab for any user of your site and get a report of their actions on your mailing list.
Further your learning
- Why would you want to show a user's MailChimp activity in Drupal instead of MailChimp?
- What new permission(s) does the MailChimp Activity module add and what do they allow?
- Further exploration: What happens if you create a MailChimp Activity entity for a entity type + bundle that doesn't have a MailChimp Lists field attached?