PHPackages                             lukeyouell/craft-mailchimplists - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. lukeyouell/craft-mailchimplists

AbandonedCraft-plugin

lukeyouell/craft-mailchimplists
===============================

Create, manage and monitor your MailChimp Lists from within Craft.

1.0.5(8y ago)2615.4k6[3 PRs](https://github.com/lukeyouell/craft-mailchimplists/pulls)1MITHTML

Since Feb 21Pushed 7y agoCompare

[ Source](https://github.com/lukeyouell/craft-mailchimplists)[ Packagist](https://packagist.org/packages/lukeyouell/craft-mailchimplists)[ RSS](/packages/lukeyouell-craft-mailchimplists/feed)WikiDiscussions v1 Synced 1mo ago

READMEChangelog (6)Dependencies (1)Versions (7)Used By (1)

[![icon](src/icon.svg)](src/icon.svg)

MailChimp Lists plugin for Craft CMS 3.x
========================================

[](#mailchimp-lists-plugin-for-craft-cms-3x)

Create, manage and monitor your MailChimp Lists from within Craft.

[![Screenshot](resources/img/screenshot.png)](resources/img/screenshot.png)

Requirements
------------

[](#requirements)

This plugin requires Craft CMS 3.0.0-RC11 or later.

Installation
------------

[](#installation)

To install the plugin, follow these instructions.

1. Open your terminal and go to your Craft project:

    ```
     cd /path/to/project

    ```
2. Then tell Composer to load the plugin:

    ```
     composer require lukeyouell/craft-mailchimplists

    ```
3. In the Control Panel, go to Settings → Plugins and click the “Install” button for MailChimp Lists.

Configuring MailChimp Lists
---------------------------

[](#configuring-mailchimp-lists)

You will be required to supply a MailChimp API key which is used to source the relevant data center and authenticate requests.

[Your API key is available here](https://admin.mailchimp.com/account/api-key-popup/).

A [MailChimp](https://mailchimp.com) account is required, if you don't already have one [click here to create one](https://mailchimp.com/signup).

Free &amp; paid plans are available.

Using MailChimp Lists
---------------------

[](#using-mailchimp-lists)

Once you have provided the plugin with your MailChimp API key you will be able to create, manage and monitor your lists directly from within Craft.

Example Form
------------

[](#example-form)

Your list subscription form template should look something like this:

```

  {{ csrfInput() }}

  Email Address

  First Name

  Last Name

```

Form Parameters
---------------

[](#form-parameters)

NameRequiredHashedExpected value`listId`YesYesThe unique id for the list`status`YesYes`subscribed`, `unsubscribed`, `cleaned` or `pending``email_address`YesNoEmail address for a subscriber`email_type`NoNo`html` or `text``merge_fields[]`NoNoAn individual merge var and value for a member`interests[]`NoNoThe name of this field is the ID of the interest in question.`language`NoNoIf set/detected, the subscriber’s language [ISO 3166 Country Code](https://dev.maxmind.com/geoip/legacy/codes/iso3166/)`vip`NoNoVIP status for subscriber`location[latitude]`NoNoSubscriber location latitude`location[longitude]`NoNoSubscriber location longitudeThe above field names are **case-sensitive**.

Redirecting After Submit
------------------------

[](#redirecting-after-submit)

If you have a `redirect` hidden input, the user will be redirected to it upon successful submission. This must also be a hashed value.

If you **don't** have a `redirect` hidden input, the plugin will respond with json (handy for debugging)

Ajax Submissions
----------------

[](#ajax-submissions)

You can optionally post submissions over Ajax if you’d like. Just send a POST request to your site with all of the same data that would normally be sent (except for the `redirect` field)

```
$('form').submit(function(ev) {
  // Prevent the form from actually submitting
  ev.preventDefault();

  // Send it to the server
  $.post({
    url: '/',
    dataType: 'json',
    data: $(this).serialize(),
    success: function(response) {
      if (response.success && response.statusCode == 200) {
        alert('Success!');
      } else if (response.statusCode !== 200) {
        alert('MailChimp error: ' + response.body.title)
      } else {
        alert('An error occurred. Please try again.');
      }
    }
  });
});
```

Example Responses
-----------------

[](#example-responses)

#### Successful

[](#successful)

```
{
   "success": true,
   "statusCode": 200,
   "reason": "OK",
   "body": {
      "id": "24d2b4y97c4fe95a2d6a3d3ba2018cb0",
      "email_address": "joe.bloggs@email.com",
      "unique_email_id": "84a5q243cd",
      "email_type": "html",
      "status": "subscribed",
      "merge_fields": {
         "FNAME": "Joe",
         "LNAME": "Bloggs",
      },
      "stats": {
         "avg_open_rate": 0,
         "avg_click_rate": 0
      },
      "ip_signup": "",
      "timestamp_signup": "",
      "ip_opt": "8.8.8.8",
      "timestamp_opt": "2018-02-21T13:37:36+00:00",
      "member_rating": 2,
      "last_changed": "2018-02-21T13:37:36+00:00",
      "language": "",
      "vip": false,
      "email_client": "",
      "location": {
         "latitude": 0,
         "longitude": 0,
         "gmtoff": 0,
         "dstoff": 0,
         "country_code": "",
         "timezone": ""
      },
      "list_id": "t74m4dbg9r"
   }
}
```

#### MailChimp Error

[](#mailchimp-error)

```
{
   "success": true,
   "statusCode": 400,
   "reason": "Bad Request",
   "body": {
      "type": "http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/",
      "title": "Member Exists",
      "status": 400,
      "detail": "joe.bloggs@email.com is already a list member. Use PUT to insert or update list members.",
      "instance": "a6d8eac9-3456-123a-a01b-22r4342d6432"
   }
}
```

#### Request Failed

[](#request-failed)

```
{
   "success": false,
   "reason": "cURL error 6: Could not resolve host: us17.api.mailchimp.co.uk (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)"
}
```

Overriding Plugin Settings
--------------------------

[](#overriding-plugin-settings)

If you create a [config file](https://craftcms.com/docs/config-settings) in your config folder called `mailchimp-lists.php`, you can override the plugin’s settings in the Control Panel. Since that config file is fully [multi-environment](https://craftcms.com/docs/multi-environment-configs) aware, this is a handy way to have different settings across multiple environments.

Here’s what that config file might look like along with a list of all of the possible values you can override.

```
