Mautic List Server Integration

I’m no API genius, but from what I can tell the integration with Mautic seems to be a piece of cake for those who are.

Just like the other list services, it would be nice to have a simple add to “Segment” and remove from segment on optin and optout. Mautic calls them segments instead of lists.

I have scoured the Internet looking for something specific to S2member and Mautic, even a hack to put into the API Notification box. And hence why I’m here.

They have full support for OAuth 1 and 2 as well as Http basic Auth. Just looking for a way to add that tid-bit is all. Or somebody who already figured it out. Thanks

1 Like

hi Gary, i am in the same situation and found ur thread. may i ask,humbly, that if you have sorted it out and if u chose Mailwizz or mautic with s2member integration?

Super easy for Mautic. There’s no checkbox opt-in with this method, though, so don’t use this technique if you need that :slight_smile:

Under API/Tracking in s2Member, I place the following in Signup Tracking and Modification Tracking. Pick whichever other notifications you need.

<img src="https://mymauticdomain.com/mtracking.gif?tags=mytags" />

I tag based on product name and then have my segments/campaigns react based on tags.

More info here: https://www.mautic.org/docs/en/contacts/contact_monitoring.html

You can also use JavaScript instead of the image, but the image works great for s2.

1 Like

Hi John -

I did get it figured out, so that when an event happened at s2member (registration) it would notify Mautic and add the subscriber to a segment. I haven’t used either platform (s2member or Mautic) in some time so some of this is from memory.

The first thing I did was add a php file called mautic-notify.php to a sub directory in my website structure (e.g. public_html/mautic-notify/mautic-notify.php). I added an index.html file in that directory too, so that random people couldn’t happen on by and see the php file. The contents of the PHP file which I got from this site are down below.

I then went to my s2member settings and under API/Notifications and under registration I built the url TO the php file putting the series of whatever Mautic field names and the corresponding s2member variables you want - like this &fieldname=%%variable%%&fieldname=%%variable%% etc etc. into the URL you are building.

So it looked something like this:
https
// exampleweb.com/mautic-notify/mautic-notify.php?keyID=blahblahcode&fname=%%user_first_name&lname=%%user_last_name%%&email=%%user_email%%

Make sure for each field name and variable set you add also has an entry under //load up the data in the file parts that look like this:

$data[ ‘first_name’ ] = $_GET[‘fname’];

You’ll also notice the keyID. That is the first variable used so that the php file won’t be called into action at random without knowing that key. So the keyID in the php file and in the URL call have to match. You may want to change that every so often…just because.

Below is the contents of my php file. I made sure that the keyID matched up - both in the file and in the url, then also made sure my Mautic url replaced [YourMauticURL.com], then made sure the formID matched the form ID in Mautic.

It may take a couple tries, but that’s what I did to get it to work. Good Luck!

<?php

if ($_GET['keyID'] === 'blahblahcode'){

    // load up the data
    $data[ 'first_name' ]  = $_GET['fname'];
    $data[ 'last_name' ]  =  $_GET['lname'];
    $data[ 'email' ]  =  $_GET['email'];

    //Get IP
    $ip = $_GET["ip"];
	
    //set Mautic form ID
    $formId = '2';
    $data[ 'formId' ] = $formId;

    // return has to be part of the form data array   
    $data[ 'return' ] = 'http://where-to-redirect.com';

    // set the payload
    // NOTE: It's confusing using 2 different $data vars... but $data is a new thing now
    $data = array ( 'mauticform' => $data );

    // Change [path-to-mautic] to URL where your Mautic is
    $formUrl = 'https://[YourMauticURL.com]/form/submit?formId=' . $formId;
    $ch      = curl_init();
    curl_setopt( $ch, CURLOPT_URL, $formUrl );
    curl_setopt( $ch, CURLOPT_POST, 1 );
    curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query( $data ) );
    curl_setopt( $ch, CURLOPT_HTTPHEADER, array ( "X-Forwarded-For: $ip" ) );
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
    $response = curl_exec( $ch );
    curl_close( $ch );

    //return $response;

}	
exit;
?>
3 Likes

I forgot to add to my post that I also used the official Mautic WP plugin to pass registered user info so that was what was taking care of the user info. So the JavaScript sending user info automatically fires upon the next page load upon login and then the img tag added the relevant tag whenever s2 runs the API/Tracking scripts (there are a number of places it can choose to do this).

Using Gary’s method I imagine you could also add a check to see if the user checked the subscribe box on checkout, but that would require additional coding to the example above and, I imagine, to make the subscribe box show.

So if you’re dealing with GPDR compliance Gary’s is a great start. I remember seeing something like it as a suggestion for a similar question from the Mautic team and almost used that method until I tried my current method and it worked.

But if you don’t need a checkbox, using the Mautic plugin and the img tag is an easier solution. You don’t even have to create a new form in Mautic :slight_smile:

And you can also use the img method to tag customers based on actions within your site. I use it to tag when my students complete a course and then move them to a different campaign, usually starting with congratulations and then nurturing and affiliate offers.

I use a method similar to Gary’s above to generate pdf receipts for my customers, but it hasn’t been firing consistently for Stripe refunds as of late.

2 Likes

wow!! thank you soooo much Gary and also bopters kind reply
amazing that people like you guys still exist in 2019 that willing to help a pure stranger on the internet.

this is very very helpful, but with my very limited programming ability i think i will take some time to digest.

do you guys happen to know all these because u guys are already some level of coder or just learnt it yourself and via mautic support team?

Anyways , i will definitely give it a try.

i just wonder why s2member wasnt built in in nature that allow integration in auto responder tagging easily…

Mautic isn’t supported in many WP plugins so it’s not that much of a surprise.

And, yes, I’ve done some programming :joy:

If you’re not worried about an opt-in checkbox just install the official Mautic plugin and use the img tag like I mentioned above. Then all you have to do is learn Mautic and not PHP or JavaScript.

1 Like

hi bopters, thanks so much
i downlaoded that plugin and able to make the mautic form shortcode added to my site and once sign up, it goes to my mautic without problem

but here is the thing, because i want my user who register in my website will be assigned a s2member subscriber level then to be added to the mautic

now i only able to pass the user directly to the mautic but wordpress doesnt make a subscirber level for him…

any clues? thanks so much in advance for your time

Ah. That would need some code. I thought you wanted to add users to Mautic after a purchase.
s2Member executes the code in API/Scripting after a registration so that’s when the tag would go to Mautic.

I’ve never done the reverse.

To do what you’re asking I would assume you’d have to create a webhook on the Mautic side and create a custom plugin for your WP installation to receive it, create or modify the user, and set the role.

I’ve never tried the s2Member API/Scripting for free accounts, but if it works the same it might be easier to have the user sign up for free membership level and then use what I suggested previously.

1 Like

thanks a lot Ric!!

i wonder if there any plugin that integrated with mautic for facebook and google one click login function.

I’m not sure what you mean. Only admins would usually ever login to Mautic.

But if you just want to share user data from WP, then the official plugin linked above does that already. So the user data would get sent no matter how a user account is created, assuming you’ve set up all the API permissions correctly on the social sites and in your WP plugin.

I haven’t used social login with s2Member, but did on some sites running WooCommerce and it ended up being too much of a hassle than a benefit. Most of my users that created accounts using Social Login forgot they used social login and reached out saying they couldn’t login, but your users are different than my users.

But I don’t think there’s an easy way to integrate Social Login w/ s2 (buttons on checkout page, etc.) and @clavaque 's plate is probably full just in catching up on bugs that have been identified in the last 2 years the plugin wasn’t supported by the former devs.

1 Like

hi Ric,
thanks so much for your guidance all the way, i figured the social plugin eventually and figured i must share it to you incase you’re interested as a professional courtesy.
i used the brainstrom mautic plugin instead and set rules, and now once user signup in my site ( i use users ultra for social login), their emails goes to mautic also.

However, i am still stuggling to solve the img tracking code. my site have like 10 products, and each product come with custom capabilities with paypal, if they purchases the product, e.g. product1, my client will be upgraded to level 1 and granted with the custom capabilities (cc) with tag product1 to read the page that i protected with.

now that may i humbly seek for your kind advice, if i wish to have this implemented to move my user from the subscriber level to the membership level 1 in different mautic segment, do i use the API/Tracking in s2 or do i use the API/listing in S2? if yes, do i put the code you mentioned above?

“< img src=“https://mymauticdomain.com/mtracking.gif?tags=mytags” />”

and mytags will be level1?

i see s2 come by default with aweber with subscriber level and level 1,2,3 etc. using API but doesnt work in mautic.

may i seek for your kind advice? sry for the long post

As above: Mautic List Server Integration

I only sell one product on each site so my tag is something like “purchased”.

<img src="https://mymauticdomain.com/mtracking.gif?tags=purchased" />

You’d have to look at the mautic docs if you want to add more tags. My guess is it’s just a comma between them, but it’s just a guess.