Sending user a personalized Push notification depending on his activity on the website

Let's look at the option to create personalized Push notifications to the particular users that are performed certain actions on the website (clicked a button, visited some specific page, filled in a form).

Push button notifications work like this:

  1. User clicks, for example, “Order now” button on your website

  2. An event "Order button is clicked” transferred to eSputnik system

  3. This event launches a previously configured script

  4. User receives a browser Push notification, for example, "Thank you for ordering!".

 

In our Push notification service, the process of this option implementation consists of the following stages:

  • Configuring your customers addresses (tokens) collecting process.

  • Configuring event transfer to the system

  • Creating a website Push notification

  • Creating and running a script

 

Configuring your customers addresses (tokens) collecting process.

You need to start with registering your project in the Google application firebase.google.com and generation of script to collect addresses (push-token) which must be added before closing tag. Details of the setup process are described in Creating web push notifications article. By the way, you can add this script using Google Tag Manager.

 

Configuring event transfer to the system

To transmit an event to the eSputnik system, insert additional lines to the previously installed address-gathering script (push-token) before the closing tag. So, command format will be:

function sendEventForToken(pushToken) {
     es('sendEvent', 'abandoned_cart', pushToken, [{“name”:”...”, “value”:”...”}, {...}, ...]);
}
es('getPushToken', sendEventForToken);

where
eventTypeKey - the name of the event;
keyValue - here we specify the value of push-token;
param_1, param_2 … param_n - the of the event parameters we shall need in eSputnik system;
value_1, value_2 … value_n - corresponding parameters value.

 

How to create your own Push notification

To create a Push notification, go to Messages menu - Notifications section and click the Push tab. For more info on Push notifications building, click  here.

 

Creating and running a script (on example of "Abandoned cart" script)

To initialize script in eSputnik system, you have to transmit the  abandoned_cart event to the system when user added goods to his cart. To do this, add the following code line up to </script> closing tag to the  addresses collecting script (push-token) of your clients:

function sendEventForToken(pushToken) {
     es('sendEvent', abandoned_cart', pushToken);
}
es('getPushToken', sendEventForToken);


After inserting this code, an event containing the unique user’s push-token will be sent to eSputnik system when he adds products to his cart. 

In order for the script to check whether customer completed his ordering or not, we need to generate a sold event. It will stop the running script if purchase (payment) is completed successfully. To do this, you need to add the code line to the addresses collecting script (push-token) on the "Thank you for ordering" page: 
 
function sendEventForToken(pushToken) {
es('sendEvent', ‘sold', pushToken);
}
es('getPushToken', sendEventForToken);
 
Now build a script that will run on this event.
 
 
The script timer value is set depending on users behavioral characteristics on your website. 
 
You can check the event generation correctness in Triggers menu of Events history tab of eSputnik system.
 
Then, test a new script.