Post

1 follower Follow
0
Avatar

Re-engage Stray Members of your WordPress Site

Martin Cogburn

Tip: Re-engage Your WordPress Members

Prerequisites

About This Tip

It’s only natural that over time some members of your WordPress (WP) website become disengaged and neglect to log in. Maybe it’s because they haven’t heard from you in a while, maybe their interest has dwindled, or maybe they just plum forgot they had a subscription to your website. Whatever the reason may be, this tip, when implemented, enables you to trigger an automated response from ONTRAPORT around a WordPress member’s last login date. Use this to send notifications to members of your WordPress website who haven’t logged in for x amount of days while re-engaging them with special offers and fresh content.

 

How It Works

Using a small snippet of PHP code embedded in your WordPress page or post, you’ll automatically remove contacts from a ‘Last Login Notification’ Step Sequence every time they successfully log into your WordPress website. This in turn will trigger a global Rule that immediately re-adds them to that Sequence, resetting a 30 day cycle. Should a member of your WordPress website neglect to log into your website for 30+ days, they’ll receive a notification email from your ‘Last Login Notification’ Sequence incentivizing them to log back in.

About the PHP Script

The basic idea is that the PHP code grabs the contact ID out of the member’s cookies (they should get ‘cookied’ on login to the membership site) and makes an API request to ONTRAPORT to remove them from the ‘Last Login Notification’ Sequence.

 

There are three things you need to update in this code to activate it:

  • //sequence ID of your ‘Last Login Notification’ sequence

    • $sequence = 'YOUR SEQUENCE ID HERE';

  • //ONTRAPORT API information

    • $appId = 'YOUR APP ID HERE';

    • $apiKey = 'YOUR API KEY HERE';

 

$sequence needs to be set to the sequence ID of your ‘Last Login Notification’ in sequence. Sequence ID is found in the URL bar of your browser when you open your Sequence to edit it. In the example below, the Sequence ID is 4.

 

lastlogin8.png

 

$appid and $apiKey need to be set to your api credentials. You can obtain these by creating a new API Key in ONTRAPORT.

 

The script is fairly simple and can be tweaked to perform a number of actions. You can update a field (create a Custom Field like "Last login" with the current date whenever someone logs in). You can have it add a tag, add a sequence, etc.

 

You can add this script anywhere on your WP site. Just copy and paste the whole contents of the file into the HTML source of any of your pages or posts. Insert it anywhere into the body. None of this code will visually display on your actual site.

 

*NOTE -  The contact must be cookied in order to pass their Contact ID to ONTRAPORT. To ensure this, add the PHP script to the very first page contacts are redirected to when they login, so you'll be sure to get everyone.

How To Build This

Build Elements

  • 1 Step Sequence

  • 1 Rule

  • 1 WordPress plugin (Exec-PHP)

  • 1 PHP script (attached below)

I. Create a ‘Last Login Notification’ Step Sequence

  1. Log into ONTRAPORT

  2. Create a new Step Sequence

  3. Add an Email Step

    1. Set it to fire 30 days after the previous step. This will notify your contacts that they haven’t logged in after 30 days. You can choose the number of days yourself.

    2. In your email content, add an offer or message to incentivize your members to log back in and check out your content.

Lastlogin1.png

 

II. Create a Rule That Adds Contacts Back Onto Your ‘Last Login Notification’ Sequence

  1. Go to the Contacts menu > Rules

  2. Create a new Rule

    1. Select the Trigger When contact is removed from Sequence

      1. Select your ‘Last Login Notification’ Sequence

    2. Select the Condition Has access to WordPress membership level

      1. Select the appropriate membership level(s) for access to your website

    3. Select the Action Add contact to Sequence

      1. Select your ‘Last Login Notification’ Sequence

  3. Save the Rule

lastlogin2.png

 

III. Install the Exec-PHP Plugin in WordPress and Add a PHP Script to Your Pages/Posts

  1. Log into your WordPress site

  2. Install the Exec-PHP plugin to your WordPress site

    1. Hover over the Plugins menu in the sidebar and select Add New

      lastlogin4.png

       

    2. Search for the Exec-PHP Plugin

      lastlogin5.png

       

    3. Once you’ve located the plugin in the search results, click Install Now

      lastlogin6.png

       

    4. Click OK

  3. Activate the Plugin

    lastlogin7.png

     

  4. Add the PHP code from the downloadable file attached below to any WordPress page, post, or widget.

    1. Our suggestion: add the PHP code to the very first page members are redirected to when they log into your WordPress site. This ensures you'll catch every login.

  5. Insert the appid, key and sequence ID variables from your ONTRAPORT API information

    1. See the About the PHP Script section above

  6. Publish the page/post/widget

 

Whenever a member logs into your site, they’re redirected to the members-only Welcome page and the script will hit the API removing them from the ‘Last Login Notification’ Sequence.

Important Facts

Caveats

WYSIWYG editors don’t handle code well. Tinymce (WordPress’s WYSIWYG editor) will break the PHP code if you view the ‘visual’ version of the page. Code must be fixed/re-pasted each time you toggle the ‘visual’ and ‘text’ tabs of a WordPress page. Therefore, insert the PHP code while in the ‘text’ tab of a WordPress page/post.

 

You have the option to completely disable the visual editor of your WordPress pages/posts in your User’s Profile settings if you choose to do so.

 

Limited Support

The Exec-PHP plugin is not an ONTRAPORT plugin. If it stops working or you run into compatibility issues with other plugins/themes/versions of WordPress, we’re unable to fix the issue.

 

Security

Executing PHP within posts/pages/widgets opens the possibility that malicious code could be executed.

 

Troubleshooting

Running a PHP script is going to require specific permissions on your site. The user will need to have execute permissions to run the PHP code. Your site will also need to be able to make HTTP POST requests (via CURL) to send the API request to ONTRAPORT. Chances are if you have WordPress running and the PilotPress plugin enabled, this is already the case. But if users aren’t being reset on your ‘Last Login Notification’ Sequence upon hitting the welcome page though everything is set up properly, you may not have proper permissions enabled.

 

 

 




Login_phpscript.txt

Please to leave a comment.