In this guide we will show you how to use the OptimizeMember API to add users to your membership site when using the OptimizeMember plugin, and an ActiveCampaign Automation.
This is somewhat advance but is not much different than other guides we have that use the OptimizeMember API. If you are familiar with those this will be easy.
Before starting, please make sure you have a general understanding of how ActiveCampign Automations work. You can read these guides from them on how to use Automations.
You can trigger an automation any way you like (with a tag, list, or other methods).
Step 1: Lets build the URL that you’ll need to use.
First, you’ll need to get your site URL and OptimizeMember API key.
To get the site URL, go to your WordPress Dashboard and then go to “Settings > General” – you will need to copy and paste your site URL into a notepad/document as we’ll start with that. For this example we’ll use https://example.com/
You’ll also need to have the OptimizeMember API and add that to the end of the URL.
https://example.com/ ?optimizemember_pro_remote_op_integration=1
Next, we’ll tell OptimizeMember we need to create a new user by adding &op=create_user to the URL.
https://example.com/?optimizemember_pro_remote_op_integration=1&op=create_user
Now we need to get the API key for OptimizeMember.
Go to your WordPress Dashboard and navigate to “OptimizeMember > API Scripting > Pro API For Remote Operations”.
Now we are going to add this to the URL by adding &api_key=1234567890abc
https://example.com/?optimizemember_pro_remote_op_integration=1&op=create_user&api_key=1234567890abc
Just change out the 1234567890abc with your own OptimizeMember API key.
Use the following Query Strings to add user details from ActiveCampaign. Note that we are using merge tags from ActiveCampaign which can be found in their guide.
&data[user_login]=%EMAIL%
&data[user_email]=%EMAIL%
&data[first_name]=%FIRSTNAME%
&data[last_name]= %LASTNAME%
Now we need to tell OptimizeMember what level and package(s) to add to the user.
We’ll be using the following query strings:
– &data[optimizemember_level]=1 (for level1) – level number (if left empty, 0 will be used)
– &data[optimizemember_ccaps]=package1,package2,package3 – packages (comma separated if more than one), Don’t have to use this one unless you want to add a package (not mandatory).
In this example I want to add a user to Level 3 and add the package “test” so we’ll add this to the URL
&data[optimizemember_level]=3&data[optimizemember_ccaps]=test
So now our URL will look like this:
You will also need the following Query Strings:
&data[notification]=1 (if is set to 1, OPM will email new user with username/password)
&data[modify_if_login_exists]=1 (Set this to 1 to modify if user exists. If data[user_login] is already present in the system, user update will be made),
&method=get (this will tell ActiveCampaign how to send this data to OptimizeMember).
Final URL for sending a webhook to OptimizeMember:
All the Query Strings that we used are found below:
&op=create_user
&api_key=1234567890abc
&data[user_login]=%EMAIL%
&data[user_email]=%EMAIL%
&data[first_name]=%FIRSTNAME%
&data[last_name]= %LASTNAME%
&data[optimizemember_level]=3
&data[optimizemember_ccaps]=test
&data[notification]=1
&data[modify_if_login_exists]=1
&method=get
You can also set the user’s EOT date (end of term) by using the following:
&data[optimizemember_auto_eot_time] =yyyy-mm-dd
The date for the EOT can be any value that PHP’s strtotime() function will understand (i.e. YYYY-MM-DD for year/month/day).
So if I wanted to set the EOT to expire on December 31st, 2022 then it would be passed as the following:
&data[optimizemember_auto_eot_time] =2022-12-31
Step 2: Setup ActiveCampaign Automation
We won’t go into detail on how to setup an automation, but what you’ll need to do is select the “WebHook” option:
Click the “+” button:
Then select “Conditions & Workflow” and finally, “Webhook”.
Then just pate in the URL that you built in step 1 above:
Click the green “Save” button, and make sure your Automation is set to “active” and you should be all set.
It is important to note that you need to ensure the URL and API key are correct. Also, any merge fields you use for first name, last name, email, you’ll want to be sure those exist on the contact. If the first name/last name is missing from the user profile in OptimizeMember then you’ll need to see which fields you are using and use the appropriate personalization tag.
Step 3: Testing
To test, just simply add a contact to your “contacts” in ActiveCampaign and add them to whatever you are using to trigger the automation and you should see the user added within a few minutes.
If you have further questions about using the OptimizeMember API, please don’t hesitate to get in touch with our support team and we’ll be happy to help.