1. Home
  2. Cookbook
  3. Campaigns
  4. Web layer showed when customer tries to leave

Web layer showed when customer tries to leave

It can be very useful to show a weblayer precisely at the time when a customer is about to switch to a different tab, about to close the tab or about to close the browser itself.

For this you need to enclose the JavaScript part of the weblayer (Code/JS) with following code:

function addEvent(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):

var self = this; // Web Layer extracted line

addEvent(document, "mouseout", function(event) {
 if((event.pageY - window.pageYOffset) < 10) {
 var triggered = true;
 // put the original Web Layer code here (except the line var self = this;)


Now once the customer goes over the upper part of their window, the banner will be shown.

Updated on August 31, 2017

Was this article helpful?

Related Articles