Mautic for Developers: connecting Drupal content to Mautic email marketing

Blog
Posted on
Mautic for Developers

Combining Drupal (CMS) and Mautic (Marketing Automation Software) is an excellent choice for managing your omnichannel digital experiences. Many organization already manage their content in Drupal. But manually duplicating it into Mautic - for a newsletter, for example - takes too much time and effort. Well, not anymore. We built a plugin to allow you to automatically send personalized Mautic emails with content straight from your Drupal CMS. The benefits are obvious: saving time, avoiding manual errors, and ensuring a consistent experience for your end users. 

In this blog, I explain the plugin we’ve built and how you can use it in your organization.

  1. Consistent content experiences across your websites and emails
  2. The functional plugin for marketers
  3. An example in real life: Inagro 
  4. The technical plugin for developers

1. Consistent content experience across website and email

An important thing in your overall communication is consistent content personalization across your website and emails. Why? To give your users a consistent experience, regardless of the touchpoint they’re using. But, at the same time, you also want your marketing team to manage this content as efficiently as possible to avoid: 

  • Duplicated content (once in your CMS, once in Mautic) 
  • The risk of mistakes, typos, and incorrect links
  • Manual interventions to send recurring emails
  • Repeating tasks as much as possible instead of using automation 

Another advantage is the ease of use for your content editors. They only need to know how to use one system: the CRM, because the content will be duplicated automatically into Mautic. Next to that, you are using the advanced features in Drupal, which are not available in Mautic. For example, the media library from which you can reuse the same assets for both your website and email marketing, moderation tools, advanced user permission…

2. The functional plugin for marketers

To make sure you can offer a consistent content experience across all your digital channels, we've built the External Content Plugin

What does the plugin do? 

It enables marketers to send automated personalized news updates with Mautic. The content of the emails comes directly from the Drupal CMS. This can be done without recurring developer involvement and manual actions in Mautic.

How does the plugin work? 

  1. Create content in Drupal: news, blogs, and other content types
  2. Tag these content types with interest categories
  3. Use the same interest categories in your newsletter subscription process 
  4. Link your Drupal with your Mautic via an API and Mautic plugin 
  5. Add email tokens in your emails to include the right personalized content directly from your Drupal and automate the email sending

A bit more in-depth explanation

In your Drupal website, you typically have news articles, blogs, products, events, and similar content types linked to certain tags or interests. When visitors subscribe to receive your newsletters (via a Mautic form), you can ask them about their interests to send them relevant and personalized updates. These categories on your subscription form are the same as the tagging of the content in your Drupal. Your Drupal site is extended with an API to send the latest content to the External Content Plugin. The business logic is in this API. It decides which content is sent to Mautic, and for which audience. The External Content Plugin needs to be enabled in Mautic and connected with the Drupal API. This plugin links the content received from the Drupal API with the email tokens

You add dynamic content to the email with tokens. Marketers can add one or multiple versions of the token into the email content at any position where they want to add the dynamic content. They can create the token dynamically. This means that they can adapt or create new personalized content per e-mail campaign without the need for a developer. 

Last but not least, you can automate the email sending as you want with Mautic. You can send it daily, weekly, or monthly. Or even use a Mautic Preference Center to send news updates at the interval of choice of each receiver. Et voila, you are good to go. Your visitors will automatically receive personalized news updates without the need for any manual interventions after the initial setup. 

Inagro case Dropsolid

3. An example in real life: Inagro

The External Content Plugin is not just a high-level concept. We’ve used it already for our clients. For Inagro, for example, we’ve built a fully autonomous, personalized email system with Drupal and Mautic. Inagro adds calendar events and global and personalized news items to their weekly news updates. Their content editors lose no time setting up all the unique emails. With full automation, each user receives a hyper-personalized weekly newsletter relevant to their profile.

4. The technical plugin for developers

The features of the plugin

Configuration form

where you can configure API settings and credentials

Logic to convert a configurable token

into actual data based on the preferences of a contact

Configurable tokens

that can be used in e-mail templates

Logic to fetch that data

from an external endpoint and embed it in the personalized email

Multiple token versions

You can use multiple versions of the token in a single email

Caching of rendered HTML

on Mautic’s side where possible

The 3 components of the plugin

1. Configuration form 

Configuration form where you can configure API settings and credentials. These will be used once we call the API. You can configure:

  • Endpoint: the URL of the API endpoint.
  • Authentication: none (Basic Authentication, Bearer Token, or Any Advanced Authorization Header) 
  • Method: GET or POST. Being able to request very advanced results by being able to POST requests. Instead of just having GET requests with a limited length of query string parameters.
  • If you have a test environment for the website and/or Mautic, the URL of the API can be changed on the fly or per environment.
2. ExternalContentEmailSubscriber: 

This is an Event Subscriber that gets triggered when an e-mail is sent out:

  • When an email is sent, the content of the email gets scanned for the use of our custom token {external_content:[key=value]}
  • If the token is found, our custom build “TokenReplacer” service gets called
3. TokenReplacer 

This will translate the used token in the email (set by the marketeer) to a request that can be understood by the API. The response of the API is returned to be rendered in the email.

  • The used email token is split up for each key-value pair.
  • Each pair is checked for reserved keys. These are specific settings that are used to manipulate the request to the server. They include the endpoint, the method (GET / POST)
  • The remaining pairs are converted into filters that are sent to the API endpoint. They can be hardcoded or fetched from contact fields in Mautic. This way, each email can be filled up with highly personalized content, depending on the values that are stored on the contact profile in Mautic.
  • The whole request is sent to the API. When we receive a response, we store it in the cache. The responded HTML output gets rendered in the email before it is sent to the contact.

 

Out of scope of this plugin

  • The sync of the preferences of a contact from an external source to Mautic
  • Any filtering or processing of external data. This means that the external source is fully responsible for the processing of the incoming request from this plugin.

 

The difference between this plugin and Mautic's build-in Dynamic Web Content (DWC)

  • Dynamic Web Content (DWC) enables you to embed personalized content into an external web page.
  • This plugin sends a personalized request to an external endpoint. The personalized response is then rendered in the e-mail that is sent to the contact.

Do you have the same need?
Feel free to use our plugin, it’s open!

More info, a demo, or some help to create a custom plugin to meet your needs?