This project is not covered by Drupal’s security advisory policy.

This module provides an advanced integration with Mautic.

Mautic to Drupal connection

JavaScript tracking

  • Embedding mtc.js - putting the Mautic script into page attachments.
  • Tracking pageviews - enable/disable tracking page visits.
  • Tracking outbound links - pageview event for external links.
  • Tracking mail links - pageview event for links like mailto:someone@example.com.
  • Tracking phone links - pageview event for links like tel:123456.
  • Tracking downloads - pageview event for links to selected file types.
  • Lead parameters - an ability to send additional data with pageview requests. For example - you can send the current user's e-mail to identify anonymous contacts in Mautic. Tokens can be used here (the module takes care of the additional cache dependencies coming from the token's contexts).
  • Script location - the module uses the Condition API to let you choose where the script should be visible. It works similar to block settings. You can track only relevant pages and save a lot of resources.

Module configuration

API connection

The module acts as a wrapper for the Mautic API library. It provides basic configuration (endpoint, credentials for Basic Auth) and allows to use API in your own code.

Unfortunately, the latest 3.1.0 release of the library has problems with Psr/Log. Therefore, I had to use the main branch. I will change it back when a new version of the library is released.

Example custom usage:

/** @var\Drupal\advanced_mautic_integration\MauticApiWrapperInterface $api_wrapper */
$api_wrapper = \Drupal::service('advanced_mautic_integration.api');
$api = $api_wrapper->getApi('contacts');
$lead_data = [
  'email' => 'someone@example.com',
  'firstname' => 'John Doe',
];
$api->create($lead_data);

For now, there is a built-in API integration that allows you to send Drupal user data to Mautic. It happens on user entity update/insert. You can set up a custom field mapping to suit your needs.

Additional information

The module is compliant with phpcs (Drupal/DrupalPractice), phpstan-drupal (at level 5) and eslint.

How does it relate to GTM?

You can achieve very similar tracking functionality with Google Tag Manager, but it's not out of the box. The module provides a simple solution that just works. In the future, it will be adjusted to use GTM as the source of the mtc.js script.

Project information

Releases