Skip to main content

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.

Metadata

Release files for wagtail-mautic-integration 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wagtail-mautic-integration 0.0.1
File Size Uploaded Provenance Actions
wagtail-mautic-integration-0.0.1.tar.gz 12.6 kB Without provenance Details for wagtail-mautic-integration-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wagtail-mautic-integration 0.0.1
File Interpreter ABI Platform Actions
wagtail_mautic_integration-0.0.1-py3-none-any.whl Python 3 none any Details for wagtail_mautic_integration-0.0.1-py3-none-any.whl

Total release size: 28.2 kB

Release files / wagtail-mautic-integration-0.0.1.tar.gz

Download URL wagtail-mautic-integration-0.0.1.tar.gz
Size 12.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b8510c322852ee84f5982642e50df74a0a5388bf85ef4dd7d1a848da40973573
BLAKE2b-256 checksum
How to use checksums
370d30e86e7570302e8456272d00fc5a7ef3fe09b1a877ddbc7bb66dfc69281c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / wagtail_mautic_integration-0.0.1-py3-none-any.whl

Download URL wagtail_mautic_integration-0.0.1-py3-none-any.whl
Size 15.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
95c721f3255369d864c2365b4dc6a2eb72bc758adb9d903083dc3d67ded309af
BLAKE2b-256 checksum
How to use checksums
e3e3a51c43d2f7b23f6446258462fc67edd09812166a536fc2f3bbf337de426f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Security for wagtail-mautic-integration 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page