As the title explains, is there any way how to make the exit intent pop up show only to users who have already added products to their cart/basket.
This would help us specifically target people who have shown interest in making the purchase.
Thanks ![]()
As the title explains, is there any way how to make the exit intent pop up show only to users who have already added products to their cart/basket.
This would help us specifically target people who have shown interest in making the purchase.
Thanks ![]()
Hey there and welcome to the Community, @user14944 ![]()
Not sure if itâs possible, but Iâll be happy to discuss it with the devs. Iâll update you tomorrow ![]()
Brilliant, thank you so much!
Hi @user14944 ![]()
Devs confirmed that itâs possible to implement this customization. Theyâll try to come up with a custom code for you, and Iâll update you once itâs ready ![]()
Thatâs great!
Please make sure it works on both desktop and mobile.
It will be a fantastic feature to have, so as not to bother users who havenât shown intent of purchasing yet.
Looking forward to it, Thanks
Thank you for waiting, @user14944!
Here is the solution from our devs:
(() => {
const HAS_ITEMS_IN_CART_COOKIE_NAME = 'woocommerce_items_in_cart';
let popupWasAlreadyOpen = false;
document.addEventListener('mouseleave', () => {
const hasItemsInCart = document.cookie.includes(HAS_ITEMS_IN_CART_COOKIE_NAME);
if (!popupWasAlreadyOpen && hasItemsInCart) {
popupWasAlreadyOpen = true;
widget.show();
}
});
})();
Just disable the Exit Intent trigger and this code to the Custom JS field on the Settings tab of your widgetâs settings.
GIve it a try and let me know if it worked ![]()
Hi Max, thank you for getting back to me.
2 things;
By disabling exit intent trigger, will it effect how the pop up perceives an exit intent?
Currently I use the below custom JS so that the exit intent pop up so that it works better on mobile. Can I just add your code to this code below?
// Function to show the Elfsight widget using the provided API method
function showElfsightPopup() {
if (typeof widget !== âundefinedâ && widget.show) {
widget.show();
}
}
// Variables to track scroll position
let lastScrollTop = window.pageYOffset || document.documentElement.scrollTop;
let scrollThreshold = window.innerHeight * 0.35; // 35% of the viewport height
// Detect upward scrolling
window.addEventListener(âscrollâ, function() {
let currentScroll = window.pageYOffset || document.documentElement.scrollTop;
if (lastScrollTop - currentScroll > scrollThreshold) {
showElfsightPopup();
}
lastScrollTop = currentScroll <= 0 ? 0 : currentScroll;
}, false);
// Detect back button press on mobile
window.addEventListener(âpopstateâ, function() {
showElfsightPopup();
});
// Push a new state into the history to enable back button detection
history.pushState(null, null, window.location.href);
// Detect visibility change event
document.addEventListener(âvisibilitychangeâ, function() {
if (document.visibilityState === âhiddenâ) {
showElfsightPopup();
}
});
Hi there @user14944 ![]()
Apologies for the delayed response!
The script will trigger the Exit Intent feature, so you donât need to have it enabled in the settings,
Our devs have also taken into account your first code and the new code wonât conflict with it. Check it out and let me know how it worked ![]()
Hi Max, thank you so much for the prompt support, will be testing it and get back to you with feedback ![]()
Hi Max, Hope you are well!
We have noticed that this pop up keeps popping up both after closing and also after applying the coupon, even when we set âFrequency - Show onceâ. Is there something we can do for this please? as it gets quite annoying closing it and reappearing.
Thanks
Hi there, @user14944 ![]()
Iâve checked your website and couldnât replicate the issue. Could you please send me a vide screencast of what you see?
Iâll be happy to look into this for you ![]()