Skip to main content

Integration of Mautic Email Marketing in Wagtail Projects.

Project description

Wagtail Mautic Integration

Integration of Mautic forms in Wagtail Projects.

Background

We needed to allow our users to subscribe to a mailing list directly from a form rendered on a Wagtail Page.

Mautic is an open-source alternative to Mailchimp and fitted our needs.

The aim of this package is to render a given Mautic Form on a Wagtail page, and send the submitted data to Mautic. Other Mautic functionalities might be added later as need arises.

Installation

Install using pip

pip install wagtail-mautic-integration

Add wagtailmautic to your installed apps. Make sure wagtail.contrib.settings is also added.

 INSTALLED_APPS = [
        ...
        "wagtailmautic",
        "wagtail.contrib.settings",
        ...
        ]

Run migrations

python manage.py migrate

Mautic API Configuration

The Mautic API needs to be enabled from Mautic. Open your Mautic instance and follow the steps below to enable the Mautic API

Mautic API Setup

Follow the steps below to ensure the Mautic API is enabled from the Mautic Settings

Mautic Settings

  1. Click on the settings icon to show the available settings
  2. Click on Configuration
  3. Select API Settings
  4. Enable API by selecting Yes. If using HTTP Basic Auth (username and password for authentication), also select Yes under Enable HTTP basic auth
  5. Don't forget to Save. You can select Save and Close to Close after saving.

Using OAuth 2

If you did not select to use HTTP basic auth, you can set up to use OAuth as below:

Mautic Settings

  1. Click on the settings icon to show the available settings
  2. Click on API Credentials. If the API Credentials option is not available, please follow the previous steps to enable the API
  3. Set up the credentials name and Redirect URL
  4. Don't forget to Save. After saving, a new page will be shown with your Client ID and Client Secret that you can use for authentication

Wagtail Mautic Settings

Mautic Settings will be automatically added to the Wagtail Admin Menu as below

Navigation in Wagtail admin

Add in the URL for your Mautic instance (including the https://) to the Mautic Url field.

Set Mautic Base Url

You can use two methods for authentication:

  • OAuth2 that requires client id and client secret from Mautic
  • Basic Authentication that needs username and password. To use Basic Auth, you must enable this on Mautic Configuration as described in the previous steps above

OAth2 OAuth2

Basic

Basic

Usage

The package provides an abstract wagtail page that uses a custom view to serve the Mautic Form.

Below is a sample snippet on how you can use it on your wagtail page that you want to serve the form.

Let us say you have a subscribe page, that should show a Mautic Form that your users can fill to subscribe to your mailing list

in your app's models.py:

from wagtail.models import Page

from wagtailmautic.models import BaseMauticFormPage


class MailingListSubscribePage(BaseMauticFormPage, Page):
    pass

Create the Page as usual in your CMS admin.

Edit the Page to add the Mautic Form ID

Form Page

Add the form in your page's template

    <form method="POST">
        {% csrf_token %}
        {{ form }}
        <div class="field">
            <button type="submit" class="button submit-button has-no-border">Submit</button>
        </div>
    </form>

The rendered page should now include a form with matching fields as setup on your Mautic form. You can see a sample page in sandbox/home/models.

Submitting will send the form data to Mautic and show the thank you message that was set

You may want to override the default provided form_thank_you_landing.html template at wagtailmautic/templates/form_thank_you_landing.html

  • First, create a templates directory in your project's root directory if it does not exist already.

  • Inside the templates directory, create a directory with the name wagtailmautic whose template we want to override.

  • Inside the wagtailmautic directory, create a file with the same name as the template we want to override. In this case, create a file named form_thank_you_landing.html.

  • Edit the new form_thank_you_landing.html template as desired.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wagtail-mautic-integration-0.0.1.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

wagtail_mautic_integration-0.0.1-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file wagtail-mautic-integration-0.0.1.tar.gz.

File metadata

File hashes

Hashes for wagtail-mautic-integration-0.0.1.tar.gz
Algorithm Hash digest
SHA256 b8510c322852ee84f5982642e50df74a0a5388bf85ef4dd7d1a848da40973573
MD5 7e47683fd7670fb7d5ac42207a3a1afb
BLAKE2b-256 370d30e86e7570302e8456272d00fc5a7ef3fe09b1a877ddbc7bb66dfc69281c

See more details on using hashes here.

File details

Details for the file wagtail_mautic_integration-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for wagtail_mautic_integration-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 95c721f3255369d864c2365b4dc6a2eb72bc758adb9d903083dc3d67ded309af
MD5 d74631d965e0003af4a58aa9f6d75c80
BLAKE2b-256 e3e3a51c43d2f7b23f6446258462fc67edd09812166a536fc2f3bbf337de426f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page