All Projects → escopecz → mautic-form-submit

escopecz / mautic-form-submit

Licence: MIT License
PHP library to forward data to a Mautic form

Programming Languages

PHP
23972 projects - #3 most used programming language

Labels

Projects that are alternatives of or similar to mautic-form-submit

mautic-cron-commands
Script to run Mautic commands from a web page.
Stars: ✭ 32 (-30.43%)
Mutual labels:  mautic
mautic-api-services
Add an external API as a service in Mautic
Stars: ✭ 13 (-71.74%)
Mutual labels:  mautic
mautic-contact-ledger
Historical accounting for contacts in Mautic.
Stars: ✭ 17 (-63.04%)
Mutual labels:  mautic
mautic-advanced-templates-bundle
Plugin extends default email template capabilities with TWIG block so you can use advanced scripting techniques like conditions, loops etc
Stars: ✭ 63 (+36.96%)
Mutual labels:  mautic
landingpress
Este é um tema wordpress extremamente simples e livre de qualquer formatação para ser usado com o plugin Elementor / This is a wordpress theme extremely simple and free from any format to be used with Elementor plugin to building Landing Pages
Stars: ✭ 13 (-71.74%)
Mutual labels:  mautic
plugin-grapesjs-builder
GrapesJS HTML and MJML integration for Mautic
Stars: ✭ 42 (-8.7%)
Mutual labels:  mautic
MauticFBAdsLeadAdsBundle
Enables synchnronization of Facebook Lead Ads as leads into Mautic.
Stars: ✭ 45 (-2.17%)
Mutual labels:  mautic
mautic-recaptcha
This Plugin brings reCAPTCHA integration to mautic.
Stars: ✭ 43 (-6.52%)
Mutual labels:  mautic
mautic-zapier
Zapier JS app communicating with Mautic
Stars: ✭ 23 (-50%)
Mutual labels:  mautic
mautic-plugin-grapesbuilder
Grapesjs integration for Mautic
Stars: ✭ 23 (-50%)
Mutual labels:  mautic
Mautic
Mautic: Open Source Marketing Automation Software.
Stars: ✭ 4,887 (+10523.91%)
Mutual labels:  mautic

PHP library for submitting Mautic Form from 3rd party app

Scrutinizer Code Quality Build Status Code Coverage

Submitting a form can get handy if you want to process the data with your app, but you want to send them to Mautic too. Mautic can then run automated tasks triggered by the form submission. Read more about it in the original post.

Since the new Mautic versions prefer cookie tracking over IP tracking which makes more tedious to submit the form as the tracked contact, this library will take care of the cookie sending via CURL. It will also listen the cookie from the response and updates the contact cookie with the values from the submit response. This way if the contact ID changes because of contact merge, the contact will continue browsing under the new contact ID.

The automatic cookie handling requires that your form will be on a page tracked by the Mautic JS tracking which provides the Mautic contact cookie in the first place.

Install

Via Composer

composer require escopecz/mautic-form-submit

Usage

// Require Composer autoloader
require __DIR__.'/vendor/autoload.php';

// Define the namespace of the Mautic object
use Escopecz\MauticFormSubmit\Mautic;

// Define the namespace of the Mautic configuration object
use Escopecz\MauticFormSubmit\Mautic\Config;

// It's optional to declare the configuration object to change some default values.
// For example to disable Curl verbose logging.
$config = new Config;
$config->setCurlVerbose(true);

// Instantiate the Mautic object with the base URL where the Mautic runs
$mautic = new Mautic('https://mymautic.com');

// Create a new instance of the Form object with the form ID 342
$form = $mautic->getForm(342);

// Submit provided data array to the form 342
$result = $form->submit(['f_email' => '[email protected]']);
  • The integer passed to the getForm() method must be ID of the Mautic form.
  • The array passed to the submit() method must be associative array of ['mautic_field_alias' => 'the_value'].

For working example see the examples dir.

Testing

composer test
composer cs
composer phpstan

PHPSTAN must be installed globally (composer global require phpstan/phpstan-shim) and will run only on PHP 7+.

Current status

Travis Scrutinizer

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].