Re-order campaigns with personalised time intervals for follow-up actions

by

Interval emailings
It's possible in Copernica to use JavaScript to determine the time interval of a follow-up action. In this script, you can use variables from your database, which makes it possible to get information from the (sub)profile that triggered the follow-up action. You use this profile to personalise the time interval of, for example, re-order messages for purchased products.

An example situation

Say, a webshop sells consumer's goods such as protein shakes or other types of nutritional goods. Every container holds a specific amount of product and has an average used amount per day. With this information, assuming that every purchase is consumed by one person only, we can estimate the time it takes to finish the product. Wouldn't it be great to be able to send your customers an email a few days before they finish the product, asking whether they'd like to re-order the product? This helps you offer your customers the best possible service, as well as giving you the chance to increase your revenue. Of course, this email does not get sent if the customer has ordered the same product in the meantime.

What does one need to set up a resell campaign?

It all starts with data. Here, we're assuming your Copernica databse is linked to your webshop and that it's filled with customer data (on profile level). In this database, there's a collection with a subprofile for every purchased product (here it's called 'Orderedproducts'). If you add to the product properties in your webshop the expected amount of days it takes for the product to run out, and synchronise this with Copernica, all subprofiles will show the re-order period in a new field (here 'Reorderperiod').

The follow-up action

To start the cycle, we use a follow-up action to set in whenever a new subprofile is added to the collection 'Orderedproducts'. We set up a condition that says the field 'Reorderperiod' may not be set to 0, as that would mean there is no know re-order period. After that, we use the option to use JavaScript to set up the time interval and in it, we place the following script:

($Quantity*$Reorderperiod-1)*86400

In the code above, we take the re-order period of the ordered product and multiply it by the amount of units ordered, as it obviously takes one longer to finish a larger amount of the product. In this case we subtract one from that, because we want Copernica to send the resell mailing one day before the customer is expected to run out. Then, because JavaScript works with seconds, we multiply that by the amound of seconds in one day (86400) to transform our output from days to seconds.

What happens next?

After calculating the time interval, we need to create a document to be sent when the follow-up action is triggered. We use Smarty to show the product details of the product to be reordered. Here's an example:

<table>
    <tr>
        <td>Name</td>       <td>{$mailing.trigger.subprofile.Productname}</td>
        <td>Image</td> <td><img src='{$mailing.trigger.subprofile.
        Imagesource}'></td>
    </tr>
</table>

This code shows us the name of the product that triggered the follow-up action along with the image, which is loaded from the location that belongs to the product.

However, in the introduction of this article we stated that we didn't want the email to be sent if the customer re-ordered the product before we estimated him to run out. To achieve this, we must add another condition to the follow-up action to be checked before sending the document. Again, we use JavaScript:

function dontPreventSending() {

    for(var i=0; i < profile.Orderproducts.length; i++) {

        if (profile.Orderproducts[i].id == subprofile.id) continue;

        if (profile.Orderproducts[i].Product_ID != subprofile.Product_ID) 
        continue;

        var date1 = Date.parse(profile.Orderproducts[i].Purchasedate);
        if (isNaN(date1)) continue;

        var date2 = Date.parse(subprofile.Purchasedate);

        if (date1 > date2) return false;

    }

    return true;

}

dontPreventSending();

The code above checks whether there's a valid reason to prevent the message from being sent: it iterates through all subprofiles in the collection 'Orderedproducts'. The first if-statement checkes whether the subprofile concerns the same purchase as the one the resell mailing was triggered by (if that's the case, we ignore it). The second one determines whether the product is the same product as the one that triggered the follow-up action. If not, that means it doesn't have anything to do with what we're trying to do, so we ignore that too. If it is the case, then, and only then, do we allow the mailing to be sent. If you want every new purchase to block the re-order messages, just remove this line: if (profile.Orderproducts[i].Product_ID !=subprofile.Product_ID) continue;

Limiting the amount of re-order messages Re-order messages generally come across as friendly and caring, but you can go overboard with them. But what if your customer buys 8 products? They'll get bombarded by your re-order mailings. In this case, you will come across as pushy and annoying.

To prevent this, we need to make a function that limits the amount of re-order mailings that get sent. First of all, we need to add another field to the profile called 'Reordercounter'. This should have a standard value of 0. If your database is already filed, you can use 'edit multiple (sub)profiles' to set all values to 0.

In our example, we're going to say that a customer may not receive more than two re-order mailings per 7 days. We do this by adding 1 to the 'Reordercounter' whenever a re-order message is sent: {math equation="x+y" x=$Herbestelcounter y=1}. A second follow-up action subtracts 1 from the value of 'Reordercounter' after 7 days ({math equation="x-y" x=$Herbestelcounter y=1}). Use your time interval for this.

Finally, we need to check whether we've already reached the maximum amount of re-order messages before we send a new one. We do this in the form of an extra condition for sending the mailings therefore we add it to our priorly created JavaScript:

function dontPreventSending() {
    if (profile.Reordercounter >= 3) return false;

    for(var i=0; i < profile.Orderproducts.length; i++) {

        if (profile.Orderproducts[i].id == subprofile.id) continue;

        if (profile.Orderproducts[i].Product_ID != subprofile.Product_ID) 
        continue;

        var date1 = Date.parse(profile.Orderproducts[i].Purchasedate);
        if (isNaN(date1)) continue;

        var date2 = Date.parse(subprofile.Purchasedate);

        if (date1 > date2) return false;

    }

    return true;

}

dontPreventSending();

Related articles

news