Mautic form on website troubles- API needed?

VPS 1 - wordpress site
CentOS 8.1
php 7.4
mysql Ver 15.1 Distrib 10.3.17-MariaDB

VPS 2 - mautic
CentOS 8.2
mautic 3.1.1 rc (from github)
php 7.3.22
mysql Ver 15.1 Distrib 10.3.17-MariaDB

*Your problem
How do I setup an API between my website von VPS 1 and mautic on VPS 2?
i have seen there is a setting in the Settings of mautic, where I can turn on API.

Maybe someone can point me in a direction, where to start and how to setup a mautic API?

There is only a contact form with 3-4 fields on my website.
When I update the form in mautic, will it get updated on my website automatically via the API?
Do I still need to copy/paste that HTML code snippet on the website?

Do I still need the mautic wordpress plugin with API enabled?

Hi, there are many was to connect.

Could you plz explain what are you planning to do?

For example:

  • wordpress form values should be added to mautic
  • certain page visits should update mautic custom fields
  • mautic form in wp should update wp user database

Since this way (using an API) is new to me, I am curious what’s possible.

Main Goals for start:

the form on the website:

*name: -> should be in mautic too
*email: -> should be in mautic too
company: -> should be in mautic too

textarea/message field: should be in the notification email (to the owner and the one who filled out the form as a kind of receipt)

the required fields should get validated (is filled out, is containing an email address) and show the help/error message beneath the form on the website if something is missing.

the tracking is already working I think. Not sure what sort of info should/could be stored in a custom field for tracking. But maybe interesting in the future.

I don’t use wp users or logged in users on wp. So the contact, that filled out the form, should basically be in mautic and receive a first welcome email.

Maybe I set up another Newsletter form, basically the same, but only 2 fields:

the newsletter form is in the footer area of the website (no pop up). Since I have many pages, it would be interesting on which page (url) the newsletter was filled out and submitted. But I guess, that’s done already.

At the moment the form is on the site, copy pasted the HTML code (from mautic) into the code section on my website. An action is triggered after successful submit - send email with content to owner and contact. Another action on the webiste is the redirect to a url after submit. A “hurray” page with some recent content and instructions (check your email and so on).

All fine and good, I still can’t figure out, how to setup the error / help messages. If you don’t fill out the email address and hit submit, the action redirect is triggered, the contact is on the “Hurray” page but no one will ever get an email nor a contact in mautic. So the validation part is not working at the moment. Hope the API is more of use in this case.

What you are requesting here are standard Mautic features, you can find everything.
Help text and validation are also in the Components - Forms area, check the tabs.

You don’t need any API.

All you need is to hook up your forms, there is a bunch of literature about this.

I know, help text, validation etc is in the compenent. I am using it. The thing is, that the validation is not working on the website and the help messages are not showing up. I can hit the submit button on an empty form, allthough name and email fields are set as required. instead of the help message getting displayed the submit action is triggered.

In the form first step - did you set to display thank you msg?

Yes, With display message, i get redirected to my homepage / start page when hitting submit, allthough the form and the required fields are empty.

If i change to Remain at form, the error message shows up in the url of the site. Since I have a redirect all 404 to start page, I get redirected on the homepage with error message in the url:


Oh. I found the problem. the script / code snippet is divided in 2 parts. The first part was missing. Sorry :confused:

I still have an issue with the message / textarea field. As soon as i use a textarea field the site is not usable anymore. the word “textarea” seems to be used also by my theme. Is there a way how I can fix this? Just rename it in the code snippet doesn’t work.

The manual code snippet implementation like I’ve seen it in a youtube video, was not working out in my case. it’s the automatic way (with javascript) that works like it should.

:slight_smile:Screenshot 2020-10-03 at 15.43.55