Passing a lead from One Mautic to another on Open Mailer

Hi All

I am trying to find a creative way for a non technical person to pass a lead from one Mautic instance to another on the event opened email.

My initial approach was to do this using a webhook and sending the post to a connector as described in @joeyk blog post: https://joeykeller.com/process-any-webhook-with-mautic-without-zapier/

My pain problem over here is that my php is not great and I cannot get the right code to capture the data.

What I did for testing was setup a campaign with an Open Decision and and Action on if opened to send webhookk to an endpoint on https://hookbin.com/. Here I can see the payload.

Then I tried to capture that data on the connector side but am unable to figure this out - lack of php knowledge.

This is the code I am trying to use:

<?php
$loginname = 'myloginname';
// Loginname of your API user
$password = 'my password';
// This is the password of the API user
$siteurl = 'mymautic.com';
// example: mymautic.com

// // receive the webhook
$HTTP_RAW_POST_DATA = file_get_contents('php://input');

// decode the incoming data
$data = json_decode($HTTP_RAW_POST_DATA,true);

// grab values
$email = $data['email'];
$firstname = $data['firstname'];
$tag = 'ACQ-1-Opened';

$curl = curl_init();
// Set some options - we are passing in a user agent too here
  curl_setopt_array($curl, array(
  CURLOPT_RETURNTRANSFER => 1,
  CURLOPT_URL => "https://".$loginname.":".$password."@".$siteurl."/api/contacts/new",
  CURLOPT_USERAGENT => 'Mautic Connector',
  CURLOPT_POST => 1,
// posting the payload
  CURLOPT_POSTFIELDS => array(
    'firstname' => $firstname,
    'email' => $email,
    'tags' => $tag
  )

));
$resp = curl_exec($curl);
curl_close($curl);

file_put_contents("webhooklog.txt",($resp.PHP_EOL),FILE_APPEND);

This is what my payload looks like

If anyone has any other ideas on how to do this would love to hear.Preformatted text

What data you eant to pass? Just email?

Yes, however I would like to add a tag as well that is static.

For anyone who is interested in this solution, here is a detailed description how to do that in my new blogpost.

1 Like

Hats off to @joeyk for writing this and especially for taking the time to walk me through it personally!! Thanks Joey!!

1 Like

Different approach but worth checking.
n8n is like zippier but self hosted.
There are modules for Mautic integration.
image

So what would be the approach? How can N8N manage a tracking pixel?

I’m very interested in finding out how n8n could catch or somehow match up the tracking.

I have n8n setup and successfully passing leads from an elementor form to mautic. Works perfectly however I am not getting previous or future tracking history of the user.

If we were to pass through the user IP would this fix up the tracking issue ?

No.
You need to fire a tracking pixel before you create a new contact with the API.
This problem is described here (you and me had a conversation on this):

There is a brilliant solution for this by Matthias Reich:

It’s in German, but he provides a very elegant code:
Problem description min 17:00
For the solution he is using a php redirect (again, brilliant!): min 23:00

Also @robm has a workaround, it is a different approach:

Taking into account that the question is how to pass a lead from one Mautic instance to another on the event opened email, this would be the approach I would take.

  1. Create a webhook node on n8n
  2. Enable webhook “open email event” on mautic with the webhook url from n8n

With that, you can receive all information about every user who opens an email as you can see on this image:

After that, you can use a mautic node to send the information to another mautic instance or do pretty much anything you want:
image