Install the MailChimp Module and Dependencies

Video loading...

  • 0:02
    Using MailChimp with Drupal 7
  • 0:04
    Install the MailChimp Module and Dependencies Series Sponsored by MailChimp
  • 0:09
    In this tutorial, we're going to locate the MailChimp module on drupal.org.
  • 0:14
    Then we'll download and install that module on our Drupal site,
  • 0:17
    as well as the MailChimp API PHP library, which is a suite of PHP functions
  • 0:23
    that was written by the MailChimp team
  • 0:25
    in order to allow you to more easily interface with their API via the PHP programming language,
  • 0:31
    which is the language that Drupal uses.
  • 0:33
    We'll also install some additional dependencies from Drupal.org, specifically
  • 0:38
    the Libraries module, which will allow us to include
  • 0:42
    the MailChimp PHP API and the Entity module.
  • 0:45
    Finally, we'll take a look at what each of these sub modules
  • 0:49
    that are contained within the MailChimp project
  • 0:52
    do, and what we might want to use them for in future lessons.
  • 0:55
    By the end of this tutorial, you should be able to install
  • 0:58
    the MailChimp module and all of its required dependencies and libraries,
  • 1:02
    and confirm that they're all working.
  • 1:03
    Let's go ahead and get started.
  • 1:06
    So we'll start on Drupal.org, specifically drupal.org/project/mailchimp
  • 1:11
    where we're going to grab the official MailChimp module for integrating with Drupal.
  • 1:17
    This particular module is maintained by the team at Think Shout
  • 1:21
    in conjunction with MailChimp in order to provide integration between
  • 1:25
    Drupal and the MailChimp service.
  • 1:27
    We're going to be using the current version of the module,
  • 1:30
    which we'll go ahead and download that in a second.
  • 1:32
    I want to point this out, though.
  • 1:34
    The MailChimp module itself, or rather the MailChimp project on Drupal.org
  • 1:38
    is actually made up of a handful of modules.
  • 1:40
    There's the MailChimp module, there's the MailChimp lists,
  • 1:44
    MailChimp signup, MailChimp campaign,
  • 1:46
    and MailChimp activity sub modules as well,
  • 1:49
    each of which perform a different piece of the solution or the puzzle of integrating
  • 1:55
    at Drupal and MailChimp.
  • 1:56
    So the main MailChimp module itself is responsible for
  • 1:59
    basically making sure that there is an API for connecting
  • 2:04
    with MailChimp service.
  • 2:06
    It handles all of the low level tasks.
  • 2:08
    On its own, it doesn't provide a whole lot of functionality
  • 2:12
    for users of your Drupal site.
  • 2:14
    To provide that functionality, you would install one or more of these sub modules,
  • 2:18
    each of which we'll have a tutorial about,
  • 2:21
    or in some cases, multiple tutorials about throughout this series.
  • 2:24
    These sub modules are MailChimp lists
  • 2:27
    which primarily handles the ability to
  • 2:29
    manage mailing lists within Drupal,
  • 2:33
    and do things like allow
  • 2:35
    a user entity within Drupal
  • 2:37
    or someone's account to be subscribed to a mailing list in MailChimp,
  • 2:41
    or really any entity for that matter.
  • 2:44
    We'll get into a lot of detail about the field that it provides
  • 2:46
    and how you can integrate this with Drupal's fields and entity system
  • 2:50
    in order to track contacts
  • 2:53
    on a mailing list within MailChimp.
  • 2:55
    The MailChimp Sign Up module allows you to create quick forms
  • 2:58
    on your site either as a page or a block
  • 3:01
    for anonymous users or authenticated users
  • 3:03
    to sign up for one or more mailing lists.
  • 3:06
    The MailChimp Campaign module allows you to send
  • 3:09
    an email campaign to one of your MailChimp mailing lists
  • 3:14
    through the Drupal user interface.
  • 3:16
    And the MailChimp Activity module allows you to monitor
  • 3:19
    some of the actions that happen
  • 3:22
    when users subscribe or receive an email and sort of their activity
  • 3:26
    within your mailing lists—you'll be able to see on a per user basis
  • 3:29
    who subscribed, how many emails have they received,
  • 3:32
    did they open them, and that kind of thing.
  • 3:34
    So what we're going to do is we're going to start by going ahead
  • 3:37
    and downloading the current version of the MailChimp module,
  • 3:40
    which right now is 7.x-3.4, so I'll download that.
  • 3:45
    And I'm going to need to install that.
  • 3:47
    So once it's downloaded, if you scroll back up here,
  • 3:52
    you'll note under Read Documentation
  • 3:55
    there's some additional documentation we can read about installing.
  • 3:58
    So I'm going to open that.
  • 4:00
    When I've got the documentation open on Drupal.org,
  • 4:02
    if you scroll down here, there's some notes about installing,
  • 4:06
    whether you're installing the 3x or the 2x version
  • 4:09
    of the module, we're using a 3x version, as you'll recall, that's what we just downloaded.
  • 4:14
    And it notes here that in order for this to work,
  • 4:16
    you're also going to need to download and install the MailChimp API library, version 2.
  • 4:22
    And for that to work, you're going to need to use the Drupal Libraries module.
  • 4:27
    So we'll go ahead and download the Libraries module as well,
  • 4:31
    and the MailChimp PHP API library.
  • 4:36
    So the Libraries module, which is at
  • 4:39
    drupal.org/project/libraries
  • 4:43
    will allow us to have a seamless way of integrating the third party
  • 4:47
    MailChimp PHP library within Drupal.
  • 4:50
    So we need to install this first.
  • 4:52
    We can just go ahead and download the current version of the Libraries module.
  • 4:56
    So I'll go and grab that, and then we're also going to need to download the MailChimp PHP library.
  • 5:01
    At the time that this was recorded, the Drupal MailChimp module
  • 5:05
    makes use of the version 2 of MailChimp's API.
  • 5:08
    Version 3 was recently released, and the module is currently in the process of being updated.
  • 5:13
    For now, we'll need to use the PHP library to integrate with version 2.
  • 5:18
    But I'm assuming that once the conversion to using MailChimp's version 3 API
  • 5:24
    is made on the Drupal side of things, everything should just continue to work
  • 5:28
    the same as it does now, you'll just be installing a different set of library files here.
  • 5:32
    So make sure you read the notes on the installation instructions
  • 5:35
    when you're installing the MailChimp module about which version of the PHP
  • 5:39
    API library from MailChimp you should use.
  • 5:42
    So we're going to use the API
  • 5:44
    V2 version of that.
  • 5:47
    The best place to find that right now
  • 5:49
    is on Bit Bucket.
  • 5:51
    So if you go to
  • 5:52
    bitbucket.org/mailchimp/mailchimp-api-php
  • 5:58
    is where the source code is for this project.
  • 6:01
    You can click on the Downloads tab on the left over here,
  • 6:04
    and then select Tags.
  • 6:06
    What I would do right now is download
  • 6:09
    the most recent tagged release
  • 6:12
    of the version 2 library.
  • 6:14
    So we're going to get 2.0.6 here, and we'll go ahead and download that.
  • 6:18
    Finally, the last piece of the puzzle that we're going to want to install
  • 6:22
    is the entity API.
  • 6:24
    If you go to drupal.org/project/entity,
  • 6:28
    there's the Contributed Entity API module.
  • 6:31
    Now, the MailChimp module doesn't specifically require this.
  • 6:35
    It's not a dependency for the MailChimp module itself,
  • 6:38
    but some of the sub modules we just talked about
  • 6:40
    like Sign Up, and Lists, do require the Entity API.
  • 6:44
    So we're going to go ahead and install it now so that it's available when we need it later.
  • 6:48
    So again, I'm just going to download the current version of the Entity API module,
  • 6:53
    which looks to be 7x1.6,
  • 6:56
    so I'll go ahead and download that.
  • 6:58
    All right, now over in my finder where I've got all those files downloaded,
  • 7:02
    I'm just going to grab all of those files
  • 7:05
    and I'm going to copy them and I'm going to move them into
  • 7:07
    my Drupal directory in the appropriate place for installing a module.
  • 7:11
    So inside of my Drupal docroot directory,
  • 7:13
    where I've just got a standard Drupal 7 at this point, nothing fancy.
  • 7:17
    I'll go to docroot, sites, all, modules.
  • 7:22
    I'm going to create a new directory here called contrib
  • 7:25
    since these are all contributed modules, this is a best practice.
  • 7:28
    And then I'll go ahead and copy those in there.
  • 7:30
    The one that I'm going to place somewhere else
  • 7:33
    is this MailChimp-MailChimp API PHP zip file.
  • 7:38
    I'm actually going to take this one and move it into the libraries directory.
  • 7:42
    So I'm going into sites, all, libraries
  • 7:46
    and we'll come back here and unzip this and talk about that in a second.
  • 7:49
    So the first thing to do will be to just
  • 7:51
    unzip all three of these.
  • 7:54
    Once the modules have been unzipped, I can delete the zip files
  • 7:59
    themselves like so, so I've now got MailChimp and its sub modules.
  • 8:04
    So inside of MailChimp there's these four sub modules we talked about
  • 8:07
    and the MailChimp.module itself which is the one that integrates really
  • 8:11
    with the API and kind of provides foundation for the other four.
  • 8:14
    The libraries module, which is going to allow us to integrate the MailChimp module
  • 8:18
    with the MailChimp PHP library,
  • 8:20
    and the entity module which is the dependency for some of the MailChimp sub modules.
  • 8:26
    The other thing I need to do is in this libraries directory,
  • 8:29
    so sites, all, libraries.
  • 8:32
    I'm just going to unzip this file that we moved there
  • 8:35
    and delete the zip file.
  • 8:37
    I'm going to rename this directory to just MailChimp.
  • 8:40
    So we're just deleting MailChimp there like so.
  • 8:44
    So now the libraries module will know where to find
  • 8:48
    the MailChimp library, the PHP code that we downloaded.
  • 8:52
    To confirm that installation instruction,
  • 8:55
    you can always look at the Read Me for the MailChimp module.
  • 8:59
    Over in my editor, if I go and open up
  • 9:02
    the Read Me for that MailChimp module,
  • 9:04
    so sites, all, modules, contrib, MailChimp,
  • 9:09
    the Read Me.txt file, it also has some installation notes,
  • 9:13
    and it tells you right here when you download and install that MailChimp API library,
  • 9:19
    it should go in sites, all, and then this directory structure.
  • 9:23
    So sites, all, libraries, MailChimp,
  • 9:26
    which is what we renamed it to, and then the source code is there.
  • 9:29
    That way, the library's module will know where to locate it. Great.
  • 9:32
    So with all of those things in place, all we've got left to do
  • 9:35
    is to install those on our Drupal site.
  • 9:37
    Over on my site, I'm going to go to the Modules tab,
  • 9:41
    I'm going to scroll down—I'll just collapse this here with all the core modules—
  • 9:44
    so we can see MailChimp, the MailChimp module itself,
  • 9:47
    and all of its submodules are here
  • 9:49
    as well as the entity API module and the libraries module.
  • 9:54
    You can see that the MailChimp module has its dependency on libraries—
  • 9:58
    it requires libraries, so we've got that and that will work just fine.
  • 10:01
    And that some of the MailChimp sub modules,
  • 10:04
    like, for example, MailChimp Campaigns, also require the
  • 10:08
    currently disabled entity API module and entity tokens modules.
  • 10:13
    Entity tokens is a sub module of the entity API module.
  • 10:17
    So let's go ahead and enable MailChimp,
  • 10:20
    Entity API, and libraries, and then Save Configuration.
  • 10:25
    Once that's done, you can confirm that this is enabled.
  • 10:29
    Take a look at the MailChimp module, if you click on Configure here,
  • 10:32
    you can see that there's a configuration screen
  • 10:34
    for the main MailChimp module, which we'll be talking about in the next tutorial
  • 10:38
    where we sign up for a MailChimp account and generate an API key for Drupal to make use of.
  • 10:43
    In this tutorial, we installed the MailChimp module and its dependencies from Drupal.org.
  • 10:48
    Those dependencies are the entity API module and the libraries module.
  • 10:52
    We also located and installed MailChimp's official PHP library,
  • 10:57
    noting that at the time of this recording,
  • 10:59
    the Drupal MailChimp module is making use of Version 2 of the API,
  • 11:03
    so we needed to make sure we use that PHP library.
  • 11:06
    This will likely change in the future
  • 11:09
    as the module gets updated to work with version 3.
  • 11:11
    Just make sure you read the Read Me instructions at that time.
  • 11:15
    And finally, we took a look at what each of the sub modules
  • 11:18
    within the main MailChimp project will be used for.
  • 11:20
    We'll be talking about each of those in more depth in future tutorials.

Install the MailChimp Module and Dependencies

Loading...

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?

Series Sponsored by MailChimp

Downloads: 
Log in or sign up to download companion files.