Introduction

Overview

Recently, one of our customers here at MemberFix needed an integration of the MemberMouse membership plugin with ConvertKit.

Actually, there is already a plugin which offers such an integration but it is very limited. It only allows you to add a tag to a new MemberMouse member (but not remove a tag). So, if you need a more sophisticated integration which involves ConvertKit sequences, forms or retrieving information about a subscriber, you’ll need a custom solution.

As an example of such integration, let’s say, for example, that we will need to assign a certain ConvertKit sequence and tag to a user who buys a MemberMouse product.

So, on your WordPress website you will need:

The integration solution

The plan for doing such an integration is to use the ConvertKit API combined with a MemberMouse Push Notification which will call a PHP script when a product is purchased.

Retrieving the ConvertKit API key

We will need the API key for the PHP script. Just login to your ConvertKit account and go to “Account settings”.

convertkit account settings - How to deeply integrate MemberMouse with ConvertKit

On the next page you will be able to see the API key.

convertkit api key - How to deeply integrate MemberMouse with ConvertKit

How to get the ConvertKit sequence ID

As I said above, we will need to add any user who subscribes to a certain ConvertKit sequence. To achieve this we will need the sequence ID first. Just click on the top “Sequences” menu.

sequence id - How to deeply integrate MemberMouse with ConvertKit

When you mouse over any of the sequences you have set up, you will see on the browser status bar the link to the sequence page which contains the sequence ID. Or you simply click on the sequence and land on the sequence page. The sequence web address contains the sequence ID.

sequence id convertkit - How to deeply integrate MemberMouse with ConvertKit

How to get the tag ID

Click on “Subscribers” top link and on the page which will open just scroll down and you will be able to see, on the right side, the list of tags.

tags page - How to deeply integrate MemberMouse with ConvertKit

When you mouse over a tag, in the browser status bar you will see a link which contains the tag ID.

tag id convertkit status bar - How to deeply integrate MemberMouse with ConvertKit

The PHP script

Now that we have the API key, the sequence ID and the tag ID we can start to build the PHP script using ConvertKit API specifications.

As mentioned earlier, this script will be called when a user buys a MemberMouse product. To accomplish this we will use a MemberMouse push notification. In the PHP script we will get the email field from the submitted form and we will use it to assign the user to a certain sequence and to add a ConvertKit tag.

Here it is the script:

<?php
if(!isset($_GET[“event_type”]))
{
// event type was not found, so exit
exit;
}
else
{
$eventType = $_GET[“event_type”];
}
$email = $_GET[“email”];
$param= array();
$param[‘api_key’] = ‘your api key here’;
$param[’email’] = $email;
$url = ‘https://api.convertkit.com/v3/courses/{sequence id here}/subscribe’;
$url2 = ‘https://api.convertkit.com/v3/tags/{tag id here}/subscribe’;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Content-Type: application/json’));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “POST”);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($param));
$results = curl_exec($ch);
curl_close($ch);$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_URL, $url2);
curl_setopt($ch2, CURLOPT_HTTPHEADER, array(‘Content-Type: application/json’));
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_POST, true);
curl_setopt($ch2, CURLOPT_CUSTOMREQUEST, “POST”);
curl_setopt($ch2, CURLOPT_POSTFIELDS, json_encode($param));
$results2 = curl_exec($ch2);
curl_close($ch2);
?>

 

*Don’t forget to add your API key along with sequence and tag IDs to the script above. You will need to upload the file (let’s name it ConvertKitAPI.php ) to your FTP.

Once you’ve uploaded the script there is one more step to do: create the MemberMouse Push Notification!

How to create the MemberMouse Push Notification

Login in to your WordPress website and go to MemberMouse > Developer Tools and click on “Create Push Notification”.

create push notification - How to deeply integrate MemberMouse with ConvertKit

Then set up the push notification. Choose “Product Purchased” for the event. You can choose the event to happen for all products or select a certain product from the drop down. Select “Call a Custom Script” for the action and enter the URL to the PHP script we have created. Then click “Save Push Notification”.

push notification settings - How to deeply integrate MemberMouse with ConvertKit

Conclusion

The integration is now complete.

When a new MemberMouse user is added, a push notification will be sent by MemberMouse (depending on the trigger event you set up for this push notification), which will call the script and cause it to be executed. You can, of course, modify and extend this script (or have us do it for you!) to your heart’s content. 

Please let me know if you have any comments or questions. Or, if you need a custom integration for MemberMouse and ConvertKit (say, for example, adding subscribers to forms, or updating subscriber details, etc.) you can hire us to do that here: MemberFix service.

Share This