Package: wagtail-mailchimp-integration
Wagtail Mailchimp IntegrationIntegrate Mailchimp in Wagtail ProjectFeaturesAdd a Mailchimp Audience Sign Up Form to your Wagtail Page.Benefit: Users can subscribe to your mailing list directly using a form hosted on your website.Integrate Mailchimp Audience subscription option to your custom form pages created withWagtail Form BuilderBenefit: You have an event registration page? Why not use it to get subscribers to your mailing list!InstallationInstall from pippipinstallwagtail-mailchimp-integrationAddwagtailmauticto your installed apps. Make surewagtail.contrib.settingsanddjango_countriesis also added.INSTALLED_APPS = [
        ...
        "wagtailmailchimp",
        "wagtail.contrib.settings",
        "django_countries",
        ...
        ]Run migrationspython manage.py migrate wagtailmailchimpUsageSettingsA Mailchimp settings section will be added to theSettingssection of the Wagtail Admin.The steps below explain how to add the setup the Mailchimp settings, as shown on the screenshot aboveClick on SettingsSelect Mailchimp SettingsAdd the Mailchimp API Key. See next section on how to obtain the API Key.Add an optional default Mailchimp Audience ID. You can follow the steps
outlinedhereSaveObtaining Mailchimp API KeyYou need to obtain your API key fromMailchimp. Mailchimp provides a free trial that can get
you started if you do not have an account yet.Below are the steps you can follow to get the API Key on Mailchimp, after logging in:Click on your account profile iconSelect Account & billingClick on Extras -> API KeyCreate a new API Key, giving it an appropriate name, for exampleCMS IntegrationCopy the API key that will be created.Adding a Mailchimp Audience Signup Form PageBelow is a sample snippet on how to set up a Wagtail page that will render a signup form to allow users signup to your
audience/mailing list# models.pyfromwagtail.modelsimportPagefromwagtailmailchimp.modelsimportAbstractMailChimpPageclassMailingListSubscribePage(AbstractMailChimpPage,Page):parent_page_types=['home.HomePage']template="path_to_template.html"content_panels=Page.content_panels+AbstractMailChimpPage.content_panelsAfter running your migrations and adding the Page from the Wagtail Admin Explorer, the editor will look similar to the
screenshot belowUnder Mailchimp Settings, you have the following fields:Mailchimp Audience- This is the Audience you want your users to sign up toDouble opt-in- Check if you want to have an extra step which includes an extra confirmation step that verifies each
email address. You can find More details on double op-tinhereSuccess Redirect Page- optional Wagtail Page to redirect to after successful submissionThank you text- Message to show after successful submission, if no success redirect page providedIn your template, theformcontext will contain the Mailchimp audience signup form.<formmethod="POST">{% csrf_token %}
    {{ form }}<divclass="field"><buttontype="submit"class="button submit-button">Submit</button></div></form>You can style the rendered form and fields as you like.Integrating Mailchimp Audience subscription option to your custom form pagesLet's say you have a single-page form that
usesWagtail Form Builder.You use this to building custom forms for collecting user information, say registrants to a workshop/event. You want to
have an option to allow these users to also subscribe to your mailing list.The screenshot below shows what you aim to achieve - adding an option to allow users subscribe to your Mailchimp
audience:The following snippet shows how you can achieve this:# models.pyfromdjango.dbimportmodelsfrommodelcluster.fieldsimportParentalKeyfromwagtail.admin.panelsimportInlinePanelfromwagtail.contrib.forms.modelsimportAbstractFormFieldfromwagtail.modelsimportPagefromwagtailmailchimp.modelsimportAbstractMailchimpIntegrationFormclassFormField(AbstractFormField):page=ParentalKey('SampleEventFormPageWithMailingListIntegration',on_delete=models.CASCADE,related_name='form_fields')classSampleEventFormPageWithMailingListIntegration(AbstractMailchimpIntegrationForm):parent_page_types=['home.HomePage']template='event_registration_page.html'landing_page_template='form_thank_you_landing.html'content_panels=Page.content_panels+AbstractMailchimpIntegrationForm.integration_panels+[InlinePanel('form_fields',label="Form fields"),]Run your migrations, and create the page from the Wagtail Admin Explorer.The editor form will look similar to below:Select the MailChimp Audience you want to integrate. This is a dropdown of the available audiences from your
Mailchimp accountSet up your custom form fields to match your Mailchimp Audience Signup Form fields. Pay attention to field types with
choices likeCheckboxes,Radio buttonsandDropdowns, as the options must exactly match your Mailchimp signup
form options.Go back to the Wagtail Admin Explorer, and locate where the page you created is listed. Hover around the page title, and
you will see a button namedMailchimp Integrationas belowClick it, and it will open a page, where you will match the Mailchimp signup form fields, with the fields in your form.Make sure you do the matching correctly as this will inform Mailchimp on how to extract your user data from your Custom
form.Once again, make sure forchoice options in your page form fieldsmatch exactly
thechoice options in your mailchimp audience signup form on MailchimpAfter following the above steps and rendering the form in your template, theJoin Our Mailing Listcheckbox will be
appended at the end of your form fields.You can try it to make sure everything works and users are being added to your mailing list before making the page
public.You can find and follow a working sample insandbox/home/models.pyfile