Practical Cases

Retargeting: How to recover empty carts?

27 SEP. 2022
La imagen no se ha cargado correctamente

Retargeting: How to recover empty carts?

The technique of retargeting is a key point  in the digital market to increase sales by encouraging or reminding unfinished purchases. It is about encouraging the user in the last stretch of the purchase or helping him in the process. But how can I develop this technique with iurny?

Push notifications for web and app have this possibility in the delivery methods section; we explain all the steps in a simple way, without you having computer knowledge.

Click on the automatic type of shipping, in the Retargeting option. Then you have to fill in the following fields:


  • Event code: This is the name you’ve given to the event on your website or app. In this example we are going to deal with the recovery of carts after the user has not finished the process on your website.
  • Delivery offset: The waiting period to select when the retargeting notification is sent, after the desired event is executed on your website.
  • Campaign validity period: Optional. To select the validity time of the campaign. If you do not set any dates, the retargeting will always be carried out.
  • Hour interval: Optional. You can select the time range to send notifications. For example, if someone abandons a cart out of range, then they will receive the notification when starting the next range. If this field is not completed, notifications will be sent all day.


Event Code:
Let’s focus on this point to teach you how to perform this step within a cart recovery strategy: sending a notification to all those users who have left the purchase page before completion. To do this, we have to copy a piece of code on the purchase page; go to your editor’s area in the html version and look for the javascript closing tag </script> and copy our code before, without duplicating that closing tag. If you don’t locate the tag, don’t worry, directly copy this piece of code to the top including the start </script> and end tags</script>. It’s very simple, just copy and paste:


// iurny utils

function sendCustomEvent(params, successCallback, errorCallback) {

  if (Notification.permission != “granted”) {



  var _successCallback = (typeof successCallback === “function”) ? successCallback : function () {};

  var _errorCallback = (typeof errorCallback === “function”) ? errorCallback : function () {};

  var key = “event_” + params.eventType + “_sentAt”;

  var lastSentDate = parseInt(localStorage.getItem(key) || “0”, 10);

  var now = (new Date()).getTime();

  var daysInMillis = params.days * 24 * 3600 * 1000;

  if (now – lastSentDate > daysInMillis) {

    indigitall.sendCustomEvent(params, function (response) {

      localStorage.setItem(key, now);


    }, _errorCallback);



// iurny retargeting

  window.addEventListener(‘unload’, function (event) {


      eventType: “cart_off“,

      days: 1,

      async: false





When copying this code you only have to take into account 2 variables that we have written in bold type. In the eventType you must put the name of the event that you will then use in the console. For example, we have called the event cart_off (in the code it will always go between the quotation mark symbols). And then there’s the number of days. We have written1, what does it mean? This specifies the number of waiting days for the user to receive another push notification even if they enter the purchase process several times without completing it. In this variable you can put the days that seem most successful to you so as not to send too many retargeting notifications since it is not recommended to use them constantly.

As you can see in the image below, we write exactly the same thing, cart_off, in the section of the event code. In the delivery offset, we have written down 2 hours so the user will receive our notification 2 hours after having closed the purchase process.

Now you only have to complete the push with an attractive title, in the body write the main message and use a photo that catches the user’s attention. Do not forget to put the link of your website so that they can make the purchase. One of the winning options is the launch of a limited-time discount to incentivize purchase. Here we remind you how to create a push.

Note: We have explained a simple method to use if you do not have the support of IT staff. On the contrary, here you have all the information that a programmer needs to perform this type of actions at an advanced level. Also this basic explanation serves if you are using our WordPress plugin, otherwise you will have to perform the capture of devices using the methods that we explain here.