Mautic Community Forums

Create custom "event type"

Hi everyone,
According to our service, we have to send custom events every an hour from Data Base to Mautic and store under contact and company to use in segment filter.
Now we sent these Custom events to Intercom and Sending blue. Is there way to create Custom “event type” in Mautic?

Example:
every our contact wallet change, and user don’t login again maybe for a month, and we need to store his wallet information in Mautic every hour (like type event = wallet changed) and do some action based on.
thanks a lot

Hi again :grinning:
up

are you looking at storing a single value for each transaction or to simply write the updated value to a custom field ?

If you are looking for different object type, this might help you: GitHub - TheDMSGroup/mautic-extended-field: Extends Mautic custom fields for scalability and HIPAA/PCI compliance.

Hi @mikew,
I’ve tried to use this extension with Mautic 3x and 4x and looks like this is not supported. Do you have different experience and would like to give some advices how to implement it in above Mautic’s versions?

M.

Hi @mikew
No. i don’t need to Custom field. I need to send custom event. like hit, like page visit. I would like to create custom event like "create profile, delete profile, invite teammate, change wallet value and etc event and update it under contacts.

1 Like

Hi,

[please read the entire post before deciding the course of action]

You can create custom events for sure. You will have to dispatch those events somewhere in Mautic plugin code and then hook some methods from event listeners only then will this have any real impact.

If you are interested in creating your own events I would encourage you to look into the core of Mautic, things that should be of interest to you are:

  • dispatchEvent method in model class (example: app/bundles/LeadBundle/Model/LeadModel.php)
  • Use constants to name the events as shown here: app/bundles/LeadBundle/LeadEvents.php
  • Investigate how dispatch event is actually called for some existing event type
  • Hook custom method/action to specific event (event type)

This can all be very nicely done and it might even make sense in some situations, but…

based on your description I do not think you need custom events. As I understand you have Mautic and one external system from which you need to send data to Mautic.

Now you can:

  • create custom api endpoints in Mautic plugin and call Mautic api from external system
  • or you can make Mautic call api of external system (Mautic even has something called integration framework which should make integration with third party systems easier and more robust).

I might be missing something but I do not see why you need to include custom events here. Even logging these changes on contact´s history tab should be doable without introducing custom events into plugin source code.

Regards, M.

1 Like

Hi @mzagmajster
Thanks for reply.
I would like to have some event under user and company (some event for contact and the other for company).
and I want to set condition based that event to move contact to some segments for send email by campaign.
Also, the following event is must send to Mautic through the server and NOT related with user activity on the website.

So this is my scenario, what is your solution?

time stamp user id event
12/22/2021 12:23 10211 Account recharge
12/23/2021 12:23 10211 withdraw
12/24/2021 23:40 10211 invite teammate

Segment A filter:
if event = withdraw
Segment B filter:
if event = invite teammate

thanks again

Hi @mohammad01 ,

so you have some data in external database that you would like to use in Mautic to build segments. I have done this before.

High overview of what you need to do is:

  1. store data in table above into Mautic (structure of the table in mautic depends a bit on what is actually relevant for you)
  2. make columns of custom table available on segments
  3. create specific segment and configure the filters

Technical overview:

  1. create custom entity named my_lead_external_events
  2. create custom endpoint and from external system call mautic endpoint
  3. store data into my_lead_external_events
  4. put event column from table my_lead_external_events on segments
  5. configure the segment via GUI as you described
  6. run mautic:segments:update

Questions:

  1. Lets say user 1021 has events as shown in the table, at the moment is user on segment A or segment B or both?
  2. What happens when in an hour you get new record for user 1021 with event: “Account recharge”, do you have to remove contact from segment A and segment B? If you are only interested in last event that occurred then you are better of with custom field in leads table (you can add it over GUI).

If you want I can offer help with plugin development. Please reach out to the company I am working with by sending an email to: info@sos-sw.com and please provide link to this post for reference.

Hope it helps.
Regards, M.

1 Like