# Mailchimp

{% hint style="success" %}
**Available for:** Preference Management Platform (PMP)

**Premium Feature:** Mailchimp&#x20;
{% endhint %}

Didomi allows you to update your Mailchimp contact attributes with the preferences collected through your preference management platform (PMP).

{% hint style="info" %}
Alternatively, the Mailchimp integration can be performed directly from the Didomi console for the Preference Management Platform (PMP).&#x20;
{% endhint %}

## Implementation

### **Connection**

Didomi connects to Mailchimp on your behalf through API calls using an API key and a server name:

* To get your Mailchimp API key follow the steps described in [this documentation](https://mailchimp.com/developer/marketing/guides/quick-start/#generate-your-api-key).
* Your server URL of your Mailchimp account: `https://<server_name>.admin.mailchimp.com/`

Your `audience_id` is also required. It is the id of your Mailchimp Audience where all the contact creations and updates will be done by Didomi. To find your audience id, in your Mailchimp account, navigte to **Audience** → **Manage audience** → **Settings** → **Audience name and default → Audience ID**

Therefore, every time preferences are collected using the Didomi Platform, it triggers the update of your Mailchimp contact property. You can use the Didomi user's property `organization_user_id` to identify and link your contacts on both platforms.

{% hint style="warning" %}
**Note**: In order to ensure that events are received, Didomi will retry at least five times in the span of five minutes before moving on when your endpoint is down.
{% endhint %}

### **Options**

* **Upsert mode**: You can choose allowing Didomi to create contacts in Mailchimp, by setting `upsert_mode` to true. Otherwise, when a consent is collected but the `organization_user_id` value does not match with any contact in Mailchimp, the consent update will not be propagated to Mailchimp.
* **Bidirectional flow**: Please note that the bidirectional flow is not supported at the moment.

### **Mapping**

Didomi uses the entity contact of Mailchimp and sends the `merge tag` property when updating a contact. Hence consent events are mapped to the merge tag of Mailchimp contacts.

{% hint style="info" %}
For the PMP preferences with boolean type, please choose type `text` while creating audience fields and merge tags: the value that will be transferred to the merge tag will be `true` or `false`.
{% endhint %}

## Configuration

Didomi needs the following configuration items to set up the connection with Mailchimp:

| Property    | Description                                                                      | Required                  |
| ----------- | -------------------------------------------------------------------------------- | ------------------------- |
| API Key     | An API key from your Mailchimp account                                           | Yes                       |
| URL         | The server URL of your Mailchimp account                                         | Yes                       |
| Audience id | The id of your audience where all contacts will be created or updated            | Yes                       |
| Upsert mode | By setting upsert\_mode to true you allow Didomi to create contacts in Mailchimp | No, Default value = false |
| Mappings    | Mapping for properties between Didomi and Mailchimp                              | Yes                       |

### Example

```javascript
{
    "type_id": "mailchimp",
    "authentication": {
        "api_key": "your_api_key",
	"url": "your_server_url"
    },
    "properties": {
        "audience_id": "your_audience_id"
    },
    "mappings": [
        {
	    "id": "EMAIL_NOTIFICATION",
	    "value": "consents_purposes_newsletter_enabled"
	}
    ],
    "upsert_mode": true
}
```
