Deliver unique codes from a campaign in a Mailchimp flow

By the end you'll have a Mailchimp flow that emails each contact their own code from your campaign. The flow asks Coupon Carrier for a code, Coupon Carrier saves it in a field on the contact, and your Mailchimp email shows it with a merge tag.

This article is for campaigns. If you use a Code Email configuration, follow How To Deliver Unique Codes in a Mailchimp Journey Using Webhooks instead.

Before you start

  • A campaign with an offer that has codes. New to campaigns? Start with Create your first campaign.
  • Mailchimp Standard or higher. On Free and Essentials you can add the Send webhook step, but Mailchimp asks you to upgrade before the flow can use it.
  • The audience your flow runs in. It has to be in the Mailchimp account you connect to the campaign.

How it works

The flow has four steps:

  1. Any trigger starts the flow, like a new signup or a tag.
  2. Send webhook tells Coupon Carrier which contact needs a code.
  3. Wait for trigger holds the contact until the code is saved.
  4. Send email sends your email with the code in it.

Coupon Carrier saves the code in a field on the contact. The field is CC_CODE   unless you choose another. About a minute later it adds the event couponcarrier_code_added   to the contact, and that event lets the contact move on to the email.

Step 1: Set up the email tool in Coupon Carrier

  1. Open your campaign. Under How people get it, find Email tool and click Set up.
  2. Click Choose a Mailchimp account and pick your account, or connect a new one.
  3. Check Field for the code. CC_CODE   is the default. To use another field, type its tag: up to 10 letters, digits or underscores.
  4. If your account has more than one audience, choose the one your flow runs in under Audience of your flow.
  5. If a yellow box asks you to create the field, click Create field. When the line under the field says the field is in your audience, you're done here.

A Mailchimp field belongs to one audience. If you later run a flow in another audience, choose that audience here and create the field there too.

Step 2: Create the flow in Mailchimp

  1. In Mailchimp, click Automations, then Build from scratch.
  2. Name the flow and choose the audience from Step 1.
  3. Click Choose a trigger and pick what starts the flow, for example Signs up for email or Tag added. Any trigger works.

You can also add the steps below to a flow you already have. Mailchimp's guide Create a Marketing Automation Flow covers the flow builder itself.

Step 3: Add the Send webhook step

The URL and the payload are in Coupon Carrier, in the Email tool row under Send webhook.

  1. In Mailchimp, click the plus icon below the trigger and choose Send webhook.
  2. Type a Webhook name, like "Coupon Carrier".
  3. In Coupon Carrier, click Copy URL next to the offer this flow gives. Paste it into URL destination.
  4. Set the Authentication type to None.
  5. Set the Content type to JSON.
  6. Copy the payload from Coupon Carrier and paste it into Payload.
  7. Click Save.

This is the payload:

{"email": "*|EMAIL|*", "id": "*|UNIQID|*"}  

Paste it as it is. Mailchimp fills in each contact's email address and ID when it sends the webhook.

Each offer has its own URL, and one Send webhook step gives one offer. The URL has a secret key in it, which is why no authentication is needed. Treat it like a password.

Step 4: Add the Wait for trigger step

  1. Click the plus icon below Send webhook and choose Wait for trigger.
  2. Choose Event API as the trigger.
  3. In Event name, enter couponcarrier_code_added  .
  4. Leave Set a time limit unchecked. With a time limit, contacts move on to the email when the time is up, even if they have no code yet.
  5. Click Save.

Don't skip this step. Without it the email can go out before the code is saved, and the contact gets an email with no code.

Step 5: Add the email

  1. Click the plus icon below Wait for trigger and choose Send email.
  2. Design your email. Put *|CC_CODE|*   where the code should show. If you chose another field in Step 1, use its tag instead.
  3. When the flow is ready, click Continue, then Turn flow on.

Step 6: Test it

The campaign is in test mode until you go live. Contacts who go through the flow get a code that starts with TEST-  , and no real codes are used.

  1. Start the flow with your own email address. How depends on your trigger: sign up to the audience, add the tag, and so on.
  2. Open your contact in Mailchimp. The field for the code now holds a TEST-   code.
  3. About a minute later, the email arrives with the code in it.

You can run 20 tests a day. Every contact who reaches the Send webhook step counts as one. To see today's count, open Test mode under Before you go live in Coupon Carrier.

Tip: Until you go live, everyone who enters the flow gets a TEST-   code, real contacts included. Go live before the flow starts picking up real contacts.

Step 7: Go live

  1. In Coupon Carrier, click Go live.
  2. Read the Go live? window and click Go live again.

From now on the flow gives out real codes. Nothing changes in Mailchimp. A contact who got a TEST-   code while you tested gets a real one the next time they go through the flow.

The results at the top of the campaign count these vouchers. Click By source to see how many went out through Mailchimp.

Common questions

Why is a contact stuck at Wait for trigger?

Coupon Carrier only adds the event after it has saved a code. No code means no event, and the contact keeps waiting. Check these:

  • The offer is turned on and has codes left. See Codes left in Offers.
  • The campaign is live or in test mode, and the email tool is turned on. A paused campaign gives no codes.
  • The payload in the Send webhook step is the one from Coupon Carrier, with both the email and the id line.
  • The URL is complete. Copy it again with Copy URL if you're not sure.
  • The flow's audience is in the Mailchimp account shown under Mailchimp account.
  • The event name in the Wait for trigger step is exactly couponcarrier_code_added  .
  • In test mode, you still have tests left today.

Coupon Carrier tries again for a few minutes and then stops. A contact who is still waiting after that needs to go through the Send webhook step again once you've fixed the cause.

Why is the code missing from my email?

  • The flow has no Wait for trigger step, or the step has a time limit, so the email went out before the code was saved.
  • The merge tag in the email doesn't match Field for the code.
  • The field isn't in the flow's audience. Open the Email tool row, choose the audience and click Create field.

How long does it take before the email goes out?

About a minute after the contact reaches the Send webhook step. A contact who was added to Mailchimp moments ago can take a few minutes longer, because Mailchimp needs a little time before a new contact can be found.

What if a contact goes through the flow twice?

They get the same code again, and no new code is used. To let people get a new code later, open the offer and set How often can one person get this offer? to Again after a number of days.

Still need help? Contact Us Contact Us