How to Add CF7 Subscribers to Specific Mailchimp Lists and Groups

Add Contact Form 7 subscribers to specific Mailchimp lists and groups

The Mailchimp for WordPress (MC4WP) plugin connects Contact Form 7 to Mailchimp. Beyond a simple “subscribe me” checkbox, you can send each form to a specific audience (list) and a specific interest group within it, all with hidden form fields.

Problem: When a visitor ticks a special checkbox in a Contact Form 7 form, their data should go to a given Mailchimp list and group. Different forms on the same site may need different lists and groups.

Solution: Use the Mailchimp for WordPress plugin and its Contact Form 7 integration, and choose the list and group per form with hidden fields.

Step 1. Connect the plugins

Install and activate Contact Form 7 and Mailchimp for WordPress, then enter your Mailchimp API key under Mailchimp for WP → Mailchimp. In Mailchimp for WP → Integrations, enable the Contact Form 7 integration.

Step 2. Add the fields to the form

In the Contact Form 7 form editor, add hidden fields for the list and the interest group, plus a visible opt-in checkbox:

<!-- Mailchimp audience (list) ID -->
<input name="_mc4wp_lists[]" type="hidden" value="de58a2b77d" />

<!-- Interest group: mc4wp-INTERESTS[category ID][] = interest ID -->
<input name="mc4wp-INTERESTS[ac42cwe23s][]" type="hidden" value="ece5cb5ed1" />

<!-- Opt-in checkbox: subscribe only if the visitor ticks it -->
<label>
    <input type="checkbox" name="mc4wp-subscribe" value="1">
    Sign me up for news, offers and events.
</label>

Replace the IDs with your own. MC4WP shows the list ID, and the IDs of interest categories and interests, under Mailchimp for WP → Mailchimp when you expand a list.

Instead of the raw checkbox you can also use the integration’s own tag, [mc4wp_checkbox "Sign me up for news, offers and events."], which renders the same checkbox.

Subscribing without a checkbox

If the form itself is a subscription form, replace the checkbox with a hidden field:

<input type="hidden" name="mc4wp-subscribe" value="1" />

Only do this when it is clear to the visitor that submitting the form subscribes them; under GDPR, consent has to be explicit.

Sending names and other fields

MC4WP passes form fields to Mailchimp merge fields by name. Name your Contact Form 7 fields with the mc4wp- prefix and the merge tag, for example [text mc4wp-FNAME] and [text mc4wp-LNAME], and the values go to the FNAME and LNAME fields of the subscriber.

NOTE: If visitors are subscribed without ticking the checkbox, check that no other form on the same page contains a hidden mc4wp-subscribe field. MC4WP processes any submitted form that contains its fields.

Sources:

  1. https://kb.mc4wp.com/add-group-choice-cf7-forms/