How to add a contact automatically to Mautic when they register on my App

Your software
My Mautic version is: 4.0.0
My PHP version is: 7.4.33
My Database type and version is: Mariadb

Your problem
My problem is:
Is it possible that whenever someone registers on my mobile App, I want to add that contact email to my Mautic contacts. How do I go about writing the code for that? Is there some documentation I can read about such an integration?

Thanks

These errors are showing in the log:

Steps I have tried to fix the problem:

Sure you can do it via the API:

https://developer.mautic.org/#create-contact

I wrote it a bit more in detail in this thread: Update the segment and create a contact from the script - #3 by dirk_s

But if you use a mobile App - is there a server side part as well? I ask, because otherwise you would need to include the API key in the mobile App, which may not be the best idea in regards to security.

Thanks a lot @dirk_s
This is very helpful.
I read about enabling API from the Configuration panel and when doing so I realized that I do not fully understand how to specify the Redirect URI if its a mobile app?

Any pointers on that?

Also forgot to mention that I am able to include the API key in my app safely.

The redirection is only needed if you chose the OAuth2 way of authentication. If you want to follow this road, I suggest to read some intro into Oauth2. For basic auth, there is no redirect URI required.

So basically each app instance should contact your mautic directly? No server app in between?

As a side note: Not sure if storing a key in an app can ever be secure?

Alternatively you can send data via tracking pixel: Managing Contacts — Mautic Documentation 0.1 documentation

Or another approach GitHub - escopecz/mautic-form-submit: PHP library to forward data to a Mautic form
Or you can use send data with webhook and process it to Mautic via Make.com

1 Like

This one is a bit more advanced than the tracking pixel approach, however it too does not require API usage: GitHub - Leuchtfeuer/mautic-identity-sync: Allow Sync of Identity from outside system e.g. CMS login, though a control pixel with parameters

2 Likes