Mautic is integrated on the system by 2 diff ways
SDK mtc()
provided by mautic platform but very limited
API api/v1/mautic/
mautic API docs endpoints https://developer.mautic.org/#endpoints Our backend hold the keys to communicate with our mautic instance, to be able to make requests add into your .env file:
MAUTIC_USER= MAUTIC_PASSWORD=
Then you can start using our MauticEvent Library to send data to the instance.
Our library use api/v1/mautic/
so if you want to ping contact instance you can do it like api/v1/mautic/{endpoint}
being "endpoint" the mautic one ex contacts/${mtcId}/edit
.
A POST request to api/v1/mautic/contacts/1/edit
will edit the contact with id 1 on mautic.
Ones an user connect into gitcoin the user is also created on mautic instance and the id from mautic is saved on our gitcoin profile model field as mautic_id
so we are able to modify user data when needed not only when the user is logged.
the file is named mautic.js and is a class object named MauticEvent
so you can use it like MauticEvent.send(data) and that request will be posted to our internal api and our internal api will ping mautic api.
For now send only point to contact operations as is intent to be used when a user is logged in and doing actions on the site.
Is a non documented mautic object with api to create dynamic data related to an user. We are using this api as a base to be able to track user actions. The format used on this events need to be very precise but as example on how it looks when you send an bulk events to an user:
MauticEvent.createEvent({
"alias": "hackathon",
"data": [
{
"name": "interest",
"attributes": {
"hackathon-slug": "hack",
"hackathon-action": "interest"
}
}
]
},
{
"alias": "products",
"data": [
{
"name": "product",
"attributes": {
"product": "hackathon",
"persona": "hackathon-hunter",
"action": "interest"
}
}
]
})
This will add to the user, 2 custom objects I previewsly created on mautic Products and Hackathons, the strings need to follow the pattern described on mautic.js or we are not going to be able to filter on our campaigns.
In this we are sending 2 custom objects to the user logged into gitcoin as a bulk request instead of doing 2 POST.
All the time using this library keep in mind is not cheap, so try to send all the action data in one request constructing you json object for mautic. Each request is x2, as we ping our api and our api will ping Mautic one (ou api act as a proxy) and as is small data doesn't take longer but doing multiple request will scalate badly and as this a marketing request sending actions, many times the user will left the page as soon as they finish the action. To avoid requests being cut we are using "keep-alive" header so the browser will try always to finish the request even if the user close the browser.