# Mailchimp

## Setup

Freshpaint uses [Mailchimp webhooks](https://mailchimp.com/developer/transactional/guides/track-respond-activity-webhooks/) to track email deliveries, opens, and more. You'll need to set up this webhook in Mailchimp with the following steps:

1. Navigate to [**Webhooks**](https://mandrillapp.com/settings/webhooks) and click **Add a Webhook** at the top of the page
2. Choose the events you want to listen for in the “Trigger on Events” section.
3. In the “Post To URL” field, input the url you can find on [Freshpaint Sources](https://app.freshpaint.io/sources) page. It will follow the format `https://api.perfalytics.com/mailchimp/<env-id>`
4. Click **Create Webhook**

## Event Schema

Freshpaint supports tracking the following events for the Mailchimp source:

* Email: send
* Email: deferral
* Email: hard\_bounce
* Email: soft\_bounce
* Email: open
* Email: click

The following properties are attached (when available) to the properties:

| Property name       | Description                                                                                                                                     |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| event               | The "Email: send"                                                                                                                               |
| email               | The recipient's email                                                                                                                           |
| mailchimp\_msg\_id  | The mailchimp internal id of the message                                                                                                        |
| sender              | The sender's email                                                                                                                              |
| state               | The state of the message (sent, rejected, spam, unsub, bounced, or soft-bounced)                                                                |
| subaccount          | The subaccount from which the message originated; if no subaccount was used, the value will be null                                             |
| subject             | The subject line of the message                                                                                                                 |
| url                 | The URL clicked (if the event is a click event)                                                                                                 |
| diag                | For bounced and soft-bounced messages, provides the specific SMTP response code and bounce description, if any, received from the remote server |
| bounce\_description | For bounced and soft-bounced messages, a short description of the bounce reason, such as bad\_mailbox or invalid\_domain                        |
| template            | The slug of the template used, if any. If no template was used, the value will be null                                                          |
| metadata            | An array of the metadata key–value pairs that were applied to the message, if any                                                               |
| tags                | A list of tags attached to the message                                                                                                          |
| clicks              | A list of click objects (see below)                                                                                                             |
| opens               | A list of open objects (see below)                                                                                                              |

###

### Opens & Clicks:

For open and click events only, a parsed version of the user agent detected for the event. The following properties will be attached if a UA was captured:

| Property Name                           | Description                                                                                                            |
| --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| user\_agent\_parsed\_\_mobile           | Whether the user agent is a mobile agent                                                                               |
| user\_agent\_parsed\_\_os\_company      | The operating system company                                                                                           |
| user\_agent\_parsed\_\_os\_company\_url | URL of the operating system company                                                                                    |
| user\_agent\_parsed\_\_os\_family       | The operating system family (i.e., Linux, Mac, or Windows)                                                             |
| user\_agent\_parsed\_\_os\_icon         | URL for an icon for the operating system                                                                               |
| user\_agent\_parsed\_\_os\_name         | The name of the operating system used for the event                                                                    |
| user\_agent\_parsed\_\_os\_url          | URL for the operating system                                                                                           |
| user\_agent\_parsed\_\_type             | The type of user agent (e.g., "browser", "email client", "robot"); these may be updated, so string values may be added |
| user\_agent\_parsed\_\_ua\_company      | Company for the user agent (specifically the browser or email client)                                                  |
| user\_agent\_parsed\_\_ua\_company\_url | URL for the user agent company                                                                                         |
| user\_agent\_parsed\_\_ua\_family       | Family for the user agent (e.g., Firefox, Chrome, Safari)                                                              |
| user\_agent\_parsed\_\_ua\_icon         | URL for an icon for the user agent                                                                                     |
| user\_agent\_parsed\_\_ua\_name         | Name of the user agent                                                                                                 |
| user\_agent\_parsed\_\_ua\_url          | URL for the user agent                                                                                                 |
| user\_agent\_parsed\_ua\_version        | Version of the user agent                                                                                              |

For open and click events only, a parsed location based on the IP may be detected for the event. The following properties will be attached if a location was captured:

| Property Name              | Description                  |
| -------------------------- | ---------------------------- |
| location\_\_country\_short | The abbreviated country name |
| location\_\_country\_long  | The full country name        |
| location\_\_region         |                              |
| location\_\_city           |                              |
| location\_\_postal\_code   |                              |
| location\_\_timezone       |                              |
| location\_\_latitude       | The latitude of the user     |
| location\_\_longitude      | The longitude of the user    |

####

#### Click Object

| Attribute name | Description                |
| -------------- | -------------------------- |
| ts             | The timestamp of the click |
| url            | The url that was clicked   |

#### Open Object

| Attribute name | Description                                                   |
| -------------- | ------------------------------------------------------------- |
| ts             | The timestamp the email was opened                            |
| ip             | The IP address where the open occurred                        |
| location       | The approximate geolocation of the IP where the open occurred |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.freshpaint.io/integrations/sources/mailchimp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
