Reengage inactive users with web push notifications

You can use web push notifications to re-engage your users in many different ways. For example you can send transactional notifications to specific users when something happen or you can send large campaigns to all your subscribers. However in this tutorial we show a way to send notifications specifically to users who become inactive.

Re-engage registered users

If your customers sign up to your website you probably have specific information about them in your database, for example:

  • last login date
  • last purchase date
  • last time they performed a specific action

Once you have that information, you can run a daily cron job on your server which runs the following steps:

  1. Find users in your database that have performed a given action N days ago (e.g. find users whose last login is 7 days ago)
  2. Send a notification to that users (e.g. “We haven’t seen you in the last week. See what’s new!”)

Re-engage anonymous users

Websites like blogs don’t require a sign up and you can’t use the previous strategy. However you can still re-engage your inactive users that haven’t visited your website recently.

You can use tags on the web push subscription to track the last visit of a browser to your website. For example:

var today = new Date().toJSON().slice(0,10); // e.g. '2018-09-20'
var userTags = ['lastseen:' + today];

// add 'lastseen:2018-09-20' to the web push subscription
// and remove any previous tag that starts with 'lastseen:'
pushpad('status', function (_, tags) {
  pushpad('subscribe', function () {
    var trash = tags ? tags.filter(function(tag) {
      return tag.startsWith('lastseen:') && userTags.indexOf(tag) < 0;
    }) : [];
    if (trash.length) pushpad('unsubscribe', function () {}, { tags: trash });
  }, { tags: userTags });

Then you can run a daily cron job on your server to send the notifications to inactive users:

$notification1 = new Pushpad\Notification(['body' => "We haven't seen you in the last week. See what's new!"]);
$notification1->broadcast(['tags' => ['lastseen:' . date('Y-m-d', strtotime('-7 days'))]]);

$notification2 = new Pushpad\Notification(['body' => "We haven't seen you in the last month. See what's new!"]);
$notification2->broadcast(['tags' => ['lastseen:' . date('Y-m-d', strtotime('-30 days'))]]);

# ...

Leave a Reply

Your email address will not be published. Required fields are marked *