Integrating Supertab with Mailchimp
Prerequisites
- A Mailchimp API key
- A Mailchimp Audience ID
Webhook Configuration
- Login to the Business Portal
- Click on your current organization and select Webhooks.
- Click on "Add Endpoint"
- We will be using the Add Contact API end point. For the endpoint URL, use your Mailchimp API URL with the audience ID:
https://{dc-id}.api.mailchimp.com/3.0/audiences/{audience id}/contacts - Select the "puchase.completed" event.

- Click "Create"
Configuring The Webhook
- Add a custom header. This is where we will provide your API key to Mailchimp. In the Key section put
Authorizationand in the Value section:Bearer {your api key} - Click the + icon to add this header.
- Click "Save"
The Mailchimp API expects data to be in format that is different than the Supertab webhook data. So we will have to transform the outgoing payload.
- Click on "Edit Transformation"

Configuring Webhook Transformation
The Mailchimp API expects data to be in format that is different than the Supertab webhook data.
- Click on "Advanced"
- Click on "Edit Transformation"
Copy and paste the following code into the code box:
function handler(webhook) {
// modify the webhook object...
webhook.payload = {
"email_channel": {
"email": webhook.payload.data.user.email,
"marketing_consent": {"status":"unknown"}
},
"merge_fields": { "FNAME": webhook.payload.data.user.first_name,
"LNAME": webhook.payload.data.user.last_name
},
"tags":["supertab"]
}
// and return it
return webhook
}
Note: This will set the "Marketing Consent" value to "unknown". Other possible values can be found in the Mailchimp documentation.
- Click "Save".
Testing
Make a purchase using Supertab. The webhook should fire and automatically add the contact into your Mailchimp audience database (as specified with the Audience ID you used).
Additionally a "supertab" tag will be saved with that contact. So that you can quickly identify email addresses that were added due to a purchase made with Supertab.
