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);
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.
Create a webhook node on n8n
Enable webhook “open email event” on mautic with the webhook url from n8n