Reading data from a form on a website

Currently, when a customer sends us an enquiry via a form, we only receive the content of the enquiry. I would like to be able to associate it with the user’s previous activity on our website.

I have an idea:

Mautic tracks every user who accesses our website (if they accept cookies). As long as they don’t leave their email address - this is only anonymous data and doesn’t appear in the contact list in Mautic.

I can’t embed a Mautic form on my website, but I can rewrite an existing form to send selected data directly to Mautic via the API.

This is where the problem arises - how does Mautic know which anonymous user to assign the form data to? I will probably have to use cookie data - we have access to this:

  • mautic_device_id
  • mtc_id
  • mtc_sid
    I guess I need to send the mtc_id parameter via the API? How exactly should I send it so that Mautic interprets it correctly and creates a new contact with form data + historical activity data for that user?

Will this even work the way I think it should?
Or does it have to be done in a completely different way?

Thank you!
Łukasz


My Mautic version is: 4.4.10

If it’s a mautic form and your mautic domain is aligned with your website domain, then this should work automatically.

I understand it is NOT a Mautic form, so yes, it takes some workaround.

One approach that has not been maintained lately but might be worth exploring and maybe taking over: GitHub - escopecz/mautic-form-submit: PHP library to forward data to a Mautic form

The other option would not be an API call (afaik there is no form submission via API!) but simply an HTTP request with the full form data (client-side via JavaScript, and thus carrying the required cookies).
→ Non-developer opinion, though :wink:

As I said before - I cannot use Mautic form in this case ;(

Sorry, somehow missed that line :slight_smile:

Yes Ekke’s solution above is the first step I would use.
However, there is an issue with posting to a mautic form from another form including the mautic ID: it doesn’t work (there are multiple threads.)

We solved this the following way:

  1. Make the copy of the form in Mautic side with the same fields.
  2. When the contact submits the form, read the mtc_id to identify the contact id in Mautic.
  3. Make an API call to assign the email address to this anon contact. (Contact will be identified and previous history preserved.)
  4. Post the form content via POST using the library mentioned by Ekke. Since the contact has an email address, no new contact will be created.

Joey