The simplest way how to submit a form data to Mautic

Update: since Mautic changed its primary tracking param from IP to cookie, the script below won’t merge the form submission with the current contact. I prepared a new PHP library which works with the cookie too.

John Linhart
Jul 16, 2015 · 2 min read

Update 2: If anyone would be interested in jQuery integration of this functionality, here you go.

In case you have your existing web app on one hand and the new marketing automation platform Mautic on the other and you want Mautic to track your form submissions, read on.

The simplest way would be to switch to Mautic Forms. Mautic lets you create many different forms which you can embed to your web app.

But that’s not the option if there is some other functionality behind your app forms and you still want Mautic to track your form submissions. There is quite a simple way how to do that.

The trick is to add another method to your script which handle the current form submission. That method takes the form data and sends them to Mautic as well.

The method can look like the following example:

You may notice that you still need a Mautic Form ID. So you have to create the Mautic Form where you’ll send the data to. It has to have the fields named the same as your form.

Also, your server has to have CURL extension allowed.

Notice that the third param is the IP address. If you want Mautic to merge the form data with an existing lead with the same IP address, this should do the trick. Otherwise Mautic will track your server IP address and in this case you might want to switch the Mautic Form to the Kiosk Mode.

Example usage:

pushMauticForm($_REQUEST, 3);// $_REQUEST can look like:
// array('email' => 'test@email.com', 'message' => 'Test message')

Your Mautic Form with ID = 3 then has to have fields called email and message.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store