Use lead information on php page

Hi,



First of all, thanks for this great product! I’ve been looking for this for a long time.



Is there a way to extract lead information for the current visitor in php? I would like to create a custom/personal page, and show information targeted for a lead profile type. So for example, suppose I have a site for selling books. When a lead has often through the thriller section, then I would like to display on the homepage the newest thriller titles.



My end goal is to have this available as a module in Drupal 8. Any help would be greatly appreciated.



Kind regards,



Bas Hekking

Hi,

First of all, thanks for this great product! I’ve been looking for this for a long time.

Is there a way to extract lead information for the current visitor in php? I would like to create a custom/personal page, and show information targeted for a lead profile type. So for example, suppose I have a site for selling books. When a lead has often through the thriller section, then I would like to display on the homepage the newest thriller titles.

My end goal is to have this available as a module in Drupal 8. Any help would be greatly appreciated.

Kind regards,

Bas Hekking

Sure it is possible. Take a look at the Mautic API and maybe you’d want to use the current Mautic-Drupal Module as a base.

Hi Escopecz,

Thanks for your answer. I’ve just tried the rest-api, which works fine. However, how can I identify the lead is on a page? Which $filter should I use for $leadApi->getList($filter)?
Is a filter on IP address the only option? There should be a better way I hope, since several people/leads could be using the same IP.

I tried $filter = ‘ipAddresses:’.$_SERVER[‘REMOTE_ADDR’] , but this doesn’t work since the ipAddress field is an array?

Never thought of getting a current lead. Mautic uses also a cookie ID as a higher layer identifier. Email is above that. But maybe you’d need some Mautic core change to search by a cookie ID if it is not available. A pull request with such functionality would be very welcome.