Adding a MailChimp Newsletter to Your Drupal Site
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:
- On the first module, add your MailChimp API key:
- To find this Key, go to your MailChimp account dashboard
- Select the API keys under the Extras:
- Get back to your MailChimp Drupal module configuration
- Click on Create a Key
- Copy the long API key into the API key field:
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:
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
- Click on Manage Fields
- Click on Add Field
You will find the newly created Mailchimp Subscription field on the list of new fields:
- 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:
- Decide which fields to share with the MailChimp service. Naturally, the Email Address is a required field:
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.
One issue I have with this module is that navigating by Configuration > Web Services > MailChimp does not take you to all the setting pages.
- Navigate instead going to /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.
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:
I found it difficult to add both a template and content from the site.
These campaigns are reflected on your MailChimp account like this:
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. You may find it is easier to do this directly from your MailChimp account.
Thank you!
Great tutorial! Thank you.