Integrating Supertab with Mailchimp

Prerequisites

  1. A Mailchimp API key
  2. A Mailchimp Audience ID

Webhook Configuration

  1. Login to the Business Portal
  2. Click on your current organization and select Webhooks.
  3. Click on "Add Endpoint"
  4. 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  
  5. Select the "puchase.completed" event.

  1. Click "Create"

Configuring The Webhook

  1. Add a custom header. This is where we will provide your API key to Mailchimp. In the Key section put Authorization  and in the Value section: Bearer {your api key}  
  2. Click the + icon to add this header.
  3. 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.

  1. Click on "Edit Transformation"

Configuring Webhook Transformation

The Mailchimp API expects data to be in format that is different than the Supertab webhook data.

  1. Click on "Advanced"
  2. 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.

  1. 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.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us