Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Adding a MailChimp Newsletter to Your Drupal Site

Parent Feed: 

Finding easy to use modules for Drupal 8 is not always easy. Often they haven't been migrated from Drupal 7. Or they are still in beta. Or the documentation is either poor or non-existent.

That's why finding the MailChimp module was a true delight. In this tutorial, you will learn how to use this module to integrate your Drupal 8 site with MailChimp newsletter service.

The MailChimp Drupal module provides full integration with the popular mailing list service. The module has a number of sub-modules. They allow you to:

  • Connect any entity that has an email address field with a MailChimp list
  • Display subscription forms
  • Add mailing list subscription to the Drupal registration form
  • Create campaigns using Drupal entities

Step #1. Installation

  • Install the module through the Extend section
  • Decide which sub-modules to activate:

 Install the Mailchimp module

  • On the first module, add your MailChimp API key:

Add your Mailchimp Key

  • To find this Key, go to your MailChimp account dashboard
  • Select the API keys under the Extras:

Select API Keys under Extras

  • Get back to your MailChimp Drupal module configuration
  • Click on Create a Key
  • Copy the long API key into the API key field:

Paste your API Key

If you don't have any lists in your MailChimp account yet:

  • Go to your MailChimp account
  • Create a list.

Now you have something to link to from your Drupal website.

Step #2. Configuration

  • Get back to your Drupal site
  • Click on the Lists tab to see all the lists available on your MailChimp account. I only have one:

Available Mailchimp Lists

The Fields tab will display all the Mailchimp Subscription fields configured on your system. At the moment there will be none.

Let's add one to your registration form. We want people to be able to signup for our newsletter as part of the registration process.

  • Go to the Configuration > Account Settings

Account Settings

  • Click on Manage Fields
  • Click on Add Field

Add Field

You will find the newly created Mailchimp Subscription field on the list of new fields:

You will see the new field listed

  • From the MailChimp List field select the list that you created in your MailChimp account.

At this point, you can decide whether you want the subscription to be the default option or not. I chose to make it the default option. New users will still be able to click to opt out from subscribing to the newsletter if they wish to:

Set the subscription as default

  • Decide which fields to share with the MailChimp service. Naturally, the Email Address is a required field:

Decide which fields to share with Mailchimp

Step #3. Creating MailChimp Subscription Forms

You may want to add a MailChimp subscription block to your Drupal pages. For example, when registration is not enabled on your site but you would like visitors to still be able to subscribe to a newsletter.

Instead of adding the subscription block to your registration page, activate the MailChimp Signup module.

The one issue I have with this module is that the navigation from Configuration > Web Services > MailChimp does not take you to all the setting pages.

  • Use this link instead: /admin/config/services/mailchimp/signup

From here you can add a signup form, selecting the list you created on your MailChimp account. You can also select the double opt-in option that makes users confirm their email address.

Add a sign up form

The signup form can be displayed as a block or a page.

Step #4. Adding MailChimp Campaigns

You can also add a MailChimp campaign by clicking on the Campaigns tab. This is the least successful part of the Drupal integration.

I found the Preview function buggy. It has a list of available MailChimp templates that you can select from. You can also add content from the site into the mailer by using tokens:

[mailchimp_campaign|entity_type=node|entity_id=1|view_mode=teaser]

Or by selecting individual nodes:

Selecting individual nodes

I found it difficult to add both a template and content from the site.

These campaigns are reflected on your MailChimp account like this:

Campaign


Conclusion

The MailChimp Drupal module is easy to use. Best of all - it has documentation. Adding subscribers to a MailChimp list using either the Drupal registration form or a block or page is no problem at all.

The sending of campaigns from the Drupal interface is trickier and it is easier to do this directly from your MailChimp account.


About the author

Born in Zambia but living now in Cape Town, South Africa, Libby Young started out as a journalist. She taught herself HTML when the company where she was an sub-editor made the transition from CD-Rom to the web 20 years ago. Since then she has developed content-rich websites using a variety of open source content management systems.

Author: 
Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web