Current version: v1.9.0

Introduction

The module synchronizes customer data, order data and shopping cart information between Magento and Maileon. Magento is the primary system, which means that the customer information in Magento is considered the main information and changes to that data are synchronized with Magento. Conversely, only certain information is synchronized: the DOI confirmation and unsubscription. For order details and cart abandonments, this information is sent to Maileon as transactions (events) and can be used either to analyze data using contact filters or to activate a trigger mailing. All functions can be set via a configuration panel in Magento.

Install the Module

Below version 1.0.8

The first step is to copy the Maileon directory into the /app/code directory of the Magento installation. If the app directory doesn't already contain a code subdirectory please create it. After this the module must be enabled using the following steps:

From version 1.8.1

Copy the Maileon plugin to the Magento root folder (/sources/magento-2/Xqueue/Maileon/). Add the following line to the Magento composer.json:

"require": {
    "xqueue/module-maileon": "^1.8"
},

"repositories": [
    {
        "type": "composer",
        "url": "https://repo.magento.com/"
    },
    {
        "name": "xqueue/module-maileon",
        "type": "path",
        "url": "sources/magento-2/Xqueue/Maileon"
    }
],

Run composer update at command line

Enable the module

Before enable the module, we must check to make sure Magento has recognize our module or not by enter the following at the command line:

php bin/magento module:status

If you follow above step, you will see this in the result:

List of disabled modules:
Xqueue_Maileon


This means the module has recognized by the system but it is still disabled. Run this command to enable it:

php bin/magento module:enable Xqueue_Maileon

If the above succeeded the following message is displayed:

The following modules has been enabled:
Xqueue_Maileon

This’s the first time you enable this module so Magento require to check and upgrade module database. We need to run this command:

php bin/magento setup:upgrade

If everything went well you can switch to Magento’s admin interface. The plugin settings are available in the following menu:

Stores -> Configuration -> Maileon

Update the Module

Copy the contents of the new version package to /sources/magento-2/Xqueue/Maileon/

Run composer update at command line

To update database schema and dependencies, run this command:

php bin/magento setup:upgrade

Configuration in Magento

The configuration can be found under “Stores” “Configuration” and, since version 1.8, can be set on Storeview level. This means, that for each Storeview, you can select an own API key, to use different Maileon accounts or you can select different DOI mail keys to send out DOIs in e.g. different languages.

General Settings

Subscriber Settings

Please note: You can only obtain significant response analyses and react appropriately when your contacts have given consent to single user tracking. Taking into account that only the double-opt-in procedure is legally safe (for German-based providers), the only permission method we can recommend is “Double Opt-in including consent to single user tracking”.

Order Confirmation Settings


Abandoned Cart Settings

Figure 7: Shopping Cart Abandonnment Mail Settings

Figure 8: Transactiontype for Cart Abandonnments



Configuring Custom Forms

In order to submit other standard or custom data to Maileon, the following scheme must be used:

Example: custom_MySpecialField



Enhancing Transactional Data

In some cases, it is required to add custom data transactions. E.g. if you use a plugin, which allows customizing products with names, custom images, etc., and the image shall be displayed in the order confirmation mail, you need to pass this URL to Maileon. Or this case, the plugin provides a simple way to add data to the transactions by overriding class “Maileon\SyncPlugin\Helper\External\Data” from an external plugin.

To ease development, we provide a test plugin that shows a minimalistic setup. In di.xml, the class is overwritten with an own implementation:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">

<preference for="Maileon\SyncPlugin\Helper\External\Data" type="Maileon\TestPlugin\Helper\External\Data" />

</config>

Investigating class “Maileon\TestPlugin\Helper\External\Data”, which is provided by the test package and can be also named freely, there are different methods that can be used.

This method adds attributes to a single product within an order. Based on the product, e.g. a URL of a custom image could be retrieved and returned in the array:
getCustomProductAttributes($product)



This method adds attributes to an order, directly. As we are working with a transaction directly, make sure to use as a key one of the valid keys provided in the transaction type definition1:

getCustomOrderTransactionAttributes($transaction_content)

This method adds attributes to single item transactions, directly. As we are working with a transaction directly, make sure to use as a key one of the valid keys provided in the transaction type definition2:

getCustomOrderExtendedTransactionAttributes($transaction_ext_content)

This method adds attributes to a single product within an card abandonment transaction. Based on the product, e.g. a URL of a custom image could be retrieved and returned in the array:

getCustomAbandonedCartProductAttributes($product)

This method adds attributes to a cart abandonment transaction, directly. As we are working with a transaction directly, make sure to use as a key one of the valid keys provided in the transaction type definition3:

getCustomAbandonedCartTransactionAttributes($transaction_content)

The data can be added e.g. by writing it to one of the free generic string fields:

$result['generic.string_1'] = "this is an additional information";

This value can then be used in a mailing to print it, use it as a link or an image URL.

The installation of the plugin is as expected done by using Composer. The first step is to copy the ‘Maileon’ directory of the test plugin into the /app/code directory of the Magento installation. If the app directory doesn’t already contain a code subdirectory please create it. After this the module must be enabled using the following steps:

Using the command line check if the module is recognized by Magento.
Type the following command:

php bin/magento module:status

This should result in the following response:

List of disabled modules:
Maileon_TestPlugin

This means that the system has recognized the synchronization module but it isn’t enabled yet.

Issue the following command to enable the module:

php bin/magento module:enable Maileon_TestPlugin

If the above succeeded the following message is displayed:

The following modules has been enabled:
- Malieon_TestPlugin

After this Magento must check and update its database. Issue the following command:

php bin/magento setup:upgrade

If everything was installed as expected, the next time e.g. an order is triggered, some additional data should be attached to it.

Figure 9: Additional information attached to a transaction



Webhook Settings in Maileon

Changed parameters in version 1.8:
Since Magento 2.4, an email can be added as newsletter subscriber for each storeview, thus, the email can exist multiple times in the Magento newsletter module. As of version 1.8 of the plugin, configuration is based on storeview level, thus, an email can be added to different Maileon newsletter accounts based on its origin. Thus, when Maileon reports back a DOI confirmation or unsubscription, it needs to identify the correct storeview for a given contact. This is done by adding a new parameter “storeview_id”.

Unsubscription Webhook Setup

The unsubscription webhook is used to synchronize Maileon unsubscribers back to Magento. To set this up in Maileon you must navigate to Settings/Webhooks. In this panel click Create new webhook. Select Unsubscription from the event dropdown. Enter the following for HTTP post URL (substituting your own domain):

http://<my domain>/rest/V1/maileon/webhook-unsubscribe

e.g.: http://maileonmagento.com/rest/V1/maileon/webhook-unsubscribe

Add the following URL parameters:

email -> contact field value -> E-mail address

token -> user-defined value -> <token>

storeview_id -> contact field value -> magento_storeview_id

The token must match the value given for the Unsubscribe Hook Token given in Magento settings.

Figure 10: Webhook Settings for Unsubscriptions

Please note: To now anonymize the contact field “magento_storeview_id” in case of an unsubscription, it is required to configure Maileon accordingly.


DOI Confirmation Webhook Setup

The DOI confirmation webhook is used to synchronize Maileon DOI confirmations back to Magento. To set this up in Maileon you must navigate to Settings/Webhooks. In this panel click Create new webhook. Select DOI Confirmation from the event dropdown. Enter the following for HTTP post URL (substituting your own domain):

http://<my domain>/rest/V1/maileon/webhook-doi_confirm

eg.: http://maileonmagento.com/rest/V1/maileon/webhook-doi_confirm

Add the following URL parameters:

email -> contact field value -> E-mail address

token -> user-defined value -> <token>

storeview_id -> contact field value -> magento_storeview_id

The token must match the value given for the DOI Hook Token given in Magento settings.

Figure 11: Webhook Settings for DOI-Confirmations


Changelog

30.08.2022 – v 1.8.9

Added payment method ID and name to order transactions

13.05.2022 – v 1.8.8

Enhancing of loading images in abandoned carts when model is not initialized in cron job, yet

11.05.2022 – v 1.8.7

25.01.2022 – v 1.8.6

Changing DB table creation to declarative model

18.01.2022 – v 1.8.5

Added thumbnail to abandoned carts transaction

19.11.2021 – v 1.8.4.1

Added description about how to enable Maileon to send contactfield storeview_id to the Magento webhook when unsubscribing

17.11.2021 – v 1.8.4

13.09.2021 – v 1.8.3

Add functionality to add separate Maileon permission for buyers

10.09.2021 – v 1.8.2

Resubscribe with same email address fix

13.07.2021 – v 1.8.1

Recreate the package to work with composer

07.07.2021 – v 1.8

04.02.2021 – v 1.7

Updated subscriber logic to support “initial” and “target” permission separately

27.01.2021 – v 1.6

Added new settings for fallback permissions for orders and cart abandonments

15.01.2021 – v 1.5

24.11.2020 – v 1.4

1 https://dev.maileon.com/api/implementation-guideline/implementation-guidelines-transactions/implementation-guidelines-order-confirmation/

2 https://dev.maileon.com/api/implementation-guideline/implementation-guidelines-transactions/implementation-guidelines-order-confirmation/#Attributes_orderitems

3 https://dev.maileon.com/api/implementation-guideline/implementation-guidelines-transactions/implementation-guidelines-shopping-cart-abandonment/