Mautic for developers: getting started and custom plugins

Blog
Posted on
Mautic for devs

I have been a Drupal developer for many years, and at Dropsolid, I was one of the first back-end developers working with Mautic. There are a lot of similarities and differences between Drupal and Mautic development. Combining both, allows our team to design, build and support frictionless digital experiences for our clients using open source technology. But getting there was quite a journey. Our developers, like myself, were a bit scared, maybe even skeptical, at first, when adopting Mautic as a new technology in our portfolio. But that absolutely changed along the way!

In this blog, I’ll share some key learnings for developers, starting with Mautic.

  1. What is Mautic, and how is it different from Drupal?
  2. The structure of Mautic
  3. Starting in Mautic as a developer 
  4. Building your first Mautic Plugin

1. What is Mautic, and how is it different from Drupal?

Mautic is an open source marketing automation platform. In fact, it's the most used open source marketing automation on the planet. Marketing teams use it to create email marketing, lead generation, webforms, and automated marketing campaigns.

It is a SaaS product that can be installed, hosted, configured, and directly used by marketers. As soon as the email-sending configuration is done, marketing teams can create emails, forms, and campaigns. This is different from Drupal projects, where site building and theming need to be done by developers before marketers can start to manage the website. However, the Mautic community is not as mature yet as the Drupal community. Mautic Inc. was born in 2019. In recent years, the community, the install base, and the number of active contributions have grown fast.

To blend the email platform into the digital experience, some customization in Mautic can be required. That this is possible, is a huge benefit of Mautic compared to proprietary Marketing Automation solutions. There are several ways to develop in Mautic. I will go deeper into this in the next part.

Let’s have a look at the comparison between Mautic and Drupal:

 MauticDrupal
Open sourceYesYes
Size of community SmallerMature
Can be used by marketers without a development track at the start YesNo
Allows custom development to meet exact client needsYes - preferably via pluginsYes - via modules
Allows integrations with other techYesYes

2. The structure of Mautic

Mautic is open source. The core code of Mautic is available to develop on. However, if you want to allow smooth updates to future versions of Mautic, it’s recommended to:

  • build plugins,
  • ensure your plugins remain available and maintained in future versions of Mautic.

Out of the box, Mautic has 2 kinds of “plugins”:

  1. Core bundles
    • These contain the required, core functions of Mautic. Compared to Drupal, these are like Core modules. They are essential for Mautic to function as it should.
    • Examples: forms, contacts, email campaigns 
    • Available in app > bundles. 
  2. Optional bundles
    • These are optional bundles that extend the core functionality of Mautic. Compared to Drupal, these are like contrib modules.
    • Examples: CRM integrations, social media aggregators, automation integrations…) 
    • Available in the plugins folder. 

The File structure looks like this: 

File structure Mautic

A brief explanation of the structure.

App: Mautic core: required functionality for Mautic to run

  • Assets: required static files like CSS code, icons, javascript…
  • Bundles: The Core bundles: see above
  • Config: Files that contain settings or variables (aka configuration) that Mautic uses.
  • Middlewares: reusable functions used throughout Mautic
  • Migrations: migration/upgrade scripts that are used to migrate data and settings to work with a newer version of Mautic.
  • Media: File structure to store assets that are uploaded to Mautic. This also contains aggregated files and other files required for rendering the Mautic UI in the browser
  • Plugins: Contains all the optional plugins
  • Themes: Contains all the email themes (templates and assets)
  • Translations: contain optional translation files 
  • Var: This is used to store cache files, log files, and outgoing emails

3. Starting in Mautic as a developer

Now that you know the overall structure of Mautic, let’s start building your first plugin. An important thing to note with Mautic, as mentioned above, is that when you download the Mautic source code, it contains both “Mautic core” and optional plugins to extend that core functionality.

If you, as a developer, want to extend that core functionality even more, that's possible. This can be done by finding or creating your own plugins and storing them in the Plugins folder. As the Plugins folder is part of Mautic core, it’s important to watch it during updates. Depending on your update strategy, it's possible that this folder gets overwritten, with a loss of data (and functionality) as a result.

The same goes for your configuration files in the App/Config folders. Making back-ups, setting up version control, and using a package manager like Composer are recommended.

4. Building your first Mautic Plugin

As explained above, you can develop bundles to enhance the core functionalities of Mautic, like forms, emails, and campaigns. I’ll give you some examples:

  • You have a need to manipulate or extend the default logic of Mautic,
  • ... 

You can also use plugins to extend Mautic capabilities with additional capabilities or integrate with external data sources. Some examples:

  • Integrating with an unsupported CRM. Existing plugins are available for some major CRM like Salesforce, Microsoft or SugarCRM.
  • Embedding custom content into emails, like Drupal
  • Custom branding of the interface
  • Extra GrapeJs blocks
  • ...