Check your version

This video covers a topic in Drupal 7 which may or may not be the version you're using. We're keeping this tutorial online as a courtesy to users of Drupal 7, but we consider it archived.

Integrate MailChimp with Views Bulk Operations

Video loading...

  • 0:02
    Using MailChimp with Drupal 7
  • 0:04
    Integrate MailChimp with Views Bulk Operations Series Sponsored by MailChimp
  • 0:09
    The MailChimp Lists module, which is one of the sub modules of the main MailChimp project,
  • 0:14
    provides integration with the Views Bulk Operations module,
  • 0:18
    another contributed module that can be used to allow site administrators to create a view,
  • 0:22
    and then use the contents of that view to create a new segment for a list in MailChimp.
  • 0:27
    This is pretty cool,
  • 0:28
    because there are a lot of things that Drupal knows about your users that MailChimp doesn't.
  • 0:32
    So can begin to create list segments that might otherwise be impossible to generate.
  • 0:36
    In this tutorial, we'll install the Views Bulk Operations module and its dependencies.
  • 0:41
    And then we'll use it to create a view of users on our site that can be filtered based on the user role,
  • 0:46
    using exposed filter.
  • 0:47
    Finally, with the Views Bulk Operations integration,
  • 0:50
    we can use that view and that filter, to create a new segment in our MailChimp mailing list
  • 0:55
    for just users that are on a specific role on our site,
  • 0:59
    like administrators, for example.
  • 1:02
    I'm assuming that you've already got some familiarity with Views.
  • 1:05
    We're going to be building a view with an exposed filter and walking through that process really quick.
  • 1:10
    If you've not used Views before, you will probably want to take some time
  • 1:13
    to brush up on the Views module, before continuing with this particular tutorial.
  • 1:19
    By the end of this tutorial, you should be able to create
  • 1:21
    a new list segment in MailChimp based on the content of a View in Drupal.
  • 1:26
    So, the first thing that we are going to need to do to get all of this working
  • 1:29
    is install the Views Bulk Operations module, or VBO for short.
  • 1:33
    If you've never used it before, the Views Bulk Operations module
  • 1:36
    works in conjunction with the Views module,
  • 1:39
    to allow you to take a list of items from Views, and apply some action to every item in that list.
  • 1:46
    In our case, that action is going to be,
  • 1:48
    take this row from the list and subscribe it to a particular mailing list or a segment of a mailing list.
  • 1:56
    But we need to start by installing the Views Bulk Operations module and its dependencies.
  • 2:00
    Its dependencies are the Views module and the C-tools module.
  • 2:05
    So, let's go and take care of that.
  • 2:07
    I'm just going to install these real quick, with Drush.
  • 2:10
    So, I'm going to do: drush dl views, and views_bulk_operations and ctools.
  • 2:19
    So, these are the three modules that we need to download.
  • 2:23
    So, I'll go ahead and download all of those.
  • 2:24
    You can find links for these modules, to download them in the notes for this video.
  • 2:29
    Once they are downloaded, I'm going to go ahead and enable the Views Bulk Operations module.
  • 2:34
    So, lets switch over to our site.
  • 2:35
    Back on my Drupal site, I'm going to go to the modules tab,
  • 2:38
    and then, I'm going to scroll down all the way to the bottom of the list, basically.
  • 2:41
    And under the Views section, I'm going to say:
  • 2:44
    enable the Views Bulk Operations module and the Views UI,
  • 2:48
    because, of course, we will need the user interface to build our View.
  • 2:51
    And then go ahead and save that.
  • 2:53
    And then, continue.
  • 2:55
    Now I'm going to create a new View.
  • 2:57
    So, I'm going to go to: Structure, Views, and then, Add new view.
  • 3:02
    I'm going to walk through this relatively quickly.
  • 3:04
    I'm assuming that people have done this before.
  • 3:06
    We will call this view a "People Finder."
  • 3:10
    And it's going to show a list of users,
  • 3:13
    because users are the thing in our case that have a MailChimp lists field attached to them.
  • 3:19
    So, List of users, it doesn't matter how it's sorted, really. So, we will just say: Unsorted.
  • 3:26
    We'll create a page. We're going to make this page live at... we will make it at: admin/people/find.
  • 3:34
    We will have it listed as a Table.
  • 3:36
    Ten items per page is fine.
  • 3:38
    Create a menu link.
  • 3:40
    We'll put that into the Management Menu. And we'll call it People Finder, like so.
  • 3:45
    And I'm going to continue and edit.
  • 3:47
    So, we've now got a view that allows us to list all of the people or user accounts on our site.
  • 3:55
    Couple of administrative things to be aware of when you are creating this view.
  • 3:58
    First of all, I would definitely make sure that you set permissions on this.
  • 4:02
    Because this is something that will allow people to subscribe users, or manage your MailChimp list.
  • 4:07
    And you don't want just anyone to do that.
  • 4:09
    I'm going to say, only people with the administer MailChimp permission
  • 4:14
    have access to view this particular View.
  • 4:18
    So, that will limit it, in our case, to just administrators.
  • 4:21
    So that should work.
  • 4:22
    And then under Menu, I'm actually going to change this to be a Menu tab, instead of a Menu normal item.
  • 4:29
    Like so.
  • 4:30
    That'll allow it to show up as a tab under the existing People menu.
  • 4:35
    OK, so now the fun stuff.
  • 4:37
    Under Fields, let's go ahead and add a new field.
  • 4:40
    And we are going to filter the list to show us only the field provided by Views Bulk Operations.
  • 4:45
    Which, you've just got this one— Bulk operations for Users.
  • 4:50
    Because we're building a list of users.
  • 4:51
    So I'll choose that, and click Apply.
  • 4:54
    Now, what I can do is, under the Bulk Operations Settings, here,
  • 5:00
    I can select what action or actions do you want someone to be able to take for each user listed in this view.
  • 5:08
    And I'm going to choose this one, right here at the top.
  • 5:11
    I would like them to be able to choose the Add to MailChimp Lists Segment.
  • 5:15
    This is the functionality that's provided by the MailChimp module.
  • 5:17
    There are some additional settings here.
  • 5:19
    Would you like to queue the operation instead of executing it immediately?
  • 5:22
    Basically, if I've got a lot of users that I'm going to subscribe to a segment,
  • 5:26
    I might want to queue this, so that its get build up into a queue,
  • 5:29
    and then Drupal can process that queue on cron.
  • 5:31
    In our case, we've only got like, twenty users on our site,
  • 5:34
    so, I'm just going to let it happen immediately.
  • 5:37
    Do you want to allow Views Bulk Operations to skip the confirmation?
  • 5:39
    No, I'm not going to do that.
  • 5:40
    Do you want to change the label for this?
  • 5:42
    No, I'm fine with the Add to MailChimp Lists Segment label.
  • 5:45
    I have to choose which field on the entity in question
  • 5:50
    is representative of a subscription to a MailChimp list.
  • 5:54
    So, this is the MailChimp lists field
  • 5:57
    that we applied to a user entity in an earlier tutorial.
  • 6:02
    So, like that.
  • 6:03
    And then...
  • 6:05
    let's see.
  • 6:06
    I believe that's it, settings wise.
  • 6:07
    Let's look at the Bulk Operations Settings real quick.
  • 6:10
    Yes, this should be fine for our particular use case.
  • 6:13
    So, we are just enabling the Add to MailChimp Lists Segment.
  • 6:16
    Functionality provided by the MailChimp module.
  • 6:18
    And we're choosing the one field that we've got configured.
  • 6:20
    Which, basically says:
  • 6:22
    Use the e-mail address for user entity as the address to put in to MailChimp.
  • 6:27
    I will say Apply that to all displays.
  • 6:30
    I'm also going to add a filter criteria, here.
  • 6:33
    So, we said that we wanted to be able to filter the list based on user roles.
  • 6:37
    So, I'll narrow this down to User, and find the roles option, like so.
  • 6:43
    Let's say, Apply this filter to all displays.
  • 6:46
    We'll go ahead and expose this filter, so that people can change it as necessary.
  • 6:50
    Everything else, I'm just going to leave as is.
  • 6:53
    So, apply all displays.
  • 6:55
    So, we now we've got a view that is a table display, that lists users,
  • 6:59
    is located at: admin/people/find,
  • 7:02
    looks like this, below.
  • 7:04
    It has this two fields; the users name, and the bulk operations field.
  • 7:09
    We are going to go ahead and rearrange these just to make it a little more user-friendly.
  • 7:14
    The bulk operations field, which is represented as this check box in the UI.
  • 7:18
    But what that one will allow to us to do is, perform anyone of these operations listed,
  • 7:22
    and we configured the Add to MailChimp Lists Segment operation.
  • 7:26
    Awesome.
  • 7:27
    I'm going to save that.
  • 7:28
    So now, if I go and view that View that we just created.
  • 7:32
    Our People Finder, here.
  • 7:34
    I can say: Let's narrow this down to a list of users that are in the administrator role.
  • 7:39
    So, I'll hit Apply.
  • 7:41
    There is one user on our site that is in the administrator role.
  • 7:45
    Let's do...
  • 7:47
    In order to make this more meaningful,
  • 7:49
    I'm going to quickly add another user to the administrator role.
  • 7:52
    So, I'm going to go to: People, and I'll find a couple of people in this list.
  • 7:57
    And I'll say: Add role administrator to those users.
  • 8:00
    Now, If I go back to our People Finder, and filter it to just the administrator role,
  • 8:05
    now there's three users here.
  • 8:07
    So, this should end up with a segment of our MailChimp mailing lists,
  • 8:12
    that are just these three users in it, when we are all done.
  • 8:14
    I'm going to click the check box, the Select all, here.
  • 8:16
    And then, I'm going to choose my operation from the Views Bulk Operations drop down.
  • 8:20
    This is our Add to MailChimp segment operation. Click Execute.
  • 8:24
    It asks me to choose which MailChimp list is this segment is going to apply to.
  • 8:29
    In this case, I want to create a new segment.
  • 8:31
    So, it's going to apply to our subscriptions field,
  • 8:34
    which, in our case, the way we have it set up, maps to the weekly newsletter field in MailChimp.
  • 8:42
    I'm going to create a new segment.
  • 8:44
    The name for our segment is going to be Administrators.
  • 8:48
    If I click Next, it's saying...
  • 8:50
    This is the conformations step that we could have optionally skipped.
  • 8:53
    But, it's saying these three people are going to have an operation performed on them.
  • 8:58
    I can go ahead and click Confirm.
  • 9:00
    The Views Bulk Operations module does its thing,
  • 9:02
    performes the action of creating a new segment in MailChimp and subscribing everyone to it.
  • 9:06
    Now, when I switch over to MailChimp, at admin.mailchimp.com,
  • 9:10
    I can go to Lists, I can choose the Weekly Newsletter list,
  • 9:14
    and if I go to the Manage subscribers tab and choose Segments,
  • 9:18
    you can see I've now got a new Administrators segment.
  • 9:21
    And if I click on that, I see the people from the list that were added to that segment.
  • 9:27
    You will notice that, actually, only one account was added here.
  • 9:30
    The reason for that is that the accounts generated with Devel Generate.
  • 9:34
    So the users... the dummy users on our site actually have invalid email addresses,
  • 9:38
    so they didn't get imported into MailChimp.
  • 9:40
    But you get the idea of how that would work.
  • 9:43
    So, in this tutorial, we installed the Views Bulk Operations module and its dependencies.
  • 9:48
    And then we created a View of users on our site,
  • 9:50
    with the ability to filter that view to those users that are just in a specific role.
  • 9:56
    Then we used the Views Bulk Operations module's MailChimp integration,
  • 10:00
    to create a new MailChimp segment based on whatever we filtered our view down to.
  • 10:06
    In our case, we filtered it down to a list of just people that were in the administrator role,
  • 10:10
    and then applied the Views Bulk Operations action to them,
  • 10:14
    and created a new list, named Administrators.
  • 10:16
    And everything worked out great.
  • 10:18
    Now, we can email or send in a campaign to just the administrators of our site.

Integrate MailChimp with Views Bulk Operations

Loading...

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?

Series Sponsored by MailChimp

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