How do I set a pop up on the home page?

Solved

How do I set a pop up on the home page?

mypartnert
Tourist
10 0 2

hello guys, i really need a help . i wanna ask about pop up, How to set the pop up so that it appears only once on the home page, because the current situation is that when you enter or click on another menu the pop up appears again?

Accepted Solutions (2)
PageFly-Amelia
Shopify Partner
626 165 238

This is an accepted solution.

You must use JavaScript to set a cookie when the popup is closed or when the user signs up for the newsletter or check for the presence of this cookie when the user visits the homepage, if the cookie is not present, trigger the popup to appear.

Please let me know if it works by giving it a Like or marking it as a solution!


➜ Optimize your Shopify store with PageFly Page Builder (Free plan available) 
➜ Weekly updated Shopify tutorials on YouTube 


All features are available from Free plan. Live Chat Support is available 24/7.

View solution in original post

PageFly-Amelia
Shopify Partner
626 165 238

This is an accepted solution.

You can try this 

// Function to set a cookie
function setCookie(cname, cvalue, exdays) {
    var d = new Date();
    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
    var expires = "expires="+d.toUTCString();
    document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}

// Function to check if a cookie exists
function getCookie(cname) {
    var name = cname + "=";
    var decodedCookie = decodeURIComponent(document.cookie);
    var ca = decodedCookie.split(';');
    for(var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') {
            c = c.substring(1);
        }
        if (c.indexOf(name) == 0) {
            return true;
        }
    }
    return false;
}

// Function to display the popup
function displayPopup() {
    if (!getCookie('visitedHomePage')) {
        // Show your popup code here
        setCookie('visitedHomePage', true, 30); // Set the cookie to expire after 30 days
    }
}

// Call the displayPopup function when the page loads
window.onload = function() {
    displayPopup();
};

Please let me know if it works by giving it a Like or marking it as a solution!


➜ Optimize your Shopify store with PageFly Page Builder (Free plan available) 
➜ Weekly updated Shopify tutorials on YouTube 


All features are available from Free plan. Live Chat Support is available 24/7.

View solution in original post

Replies 15 (15)

PageFly-Amelia
Shopify Partner
626 165 238

Hello @mypartnert 

This is Amelia at PageFly - Shopify Advanced Page Builder app.

 

Could you please share the URL link of your store so we can check it for you?

Please let me know if it works by giving it a Like or marking it as a solution!


➜ Optimize your Shopify store with PageFly Page Builder (Free plan available) 
➜ Weekly updated Shopify tutorials on YouTube 


All features are available from Free plan. Live Chat Support is available 24/7.

mypartnert
Tourist
10 0 2

the url https://www.laicaactive.com/

now I have succeeded in editing the theme.js code. The pop only appears on the home page before appearing on every menu. but the problem is now. If we go back to the home page from another menu, even though it has previously been closed, it still appears again. I don't know why

PageFly-Amelia
Shopify Partner
626 165 238

This is an accepted solution.

You must use JavaScript to set a cookie when the popup is closed or when the user signs up for the newsletter or check for the presence of this cookie when the user visits the homepage, if the cookie is not present, trigger the popup to appear.

Please let me know if it works by giving it a Like or marking it as a solution!


➜ Optimize your Shopify store with PageFly Page Builder (Free plan available) 
➜ Weekly updated Shopify tutorials on YouTube 


All features are available from Free plan. Live Chat Support is available 24/7.

PageFly-Amelia
Shopify Partner
626 165 238

I recommend you check settings of your newsletter from your theme customize or you can contact support of that theme and ask for your request. 

Please let me know if it works by giving it a Like or marking it as a solution!


➜ Optimize your Shopify store with PageFly Page Builder (Free plan available) 
➜ Weekly updated Shopify tutorials on YouTube 


All features are available from Free plan. Live Chat Support is available 24/7.

mypartnert
Tourist
10 0 2

Thank you for your response, but is it possible on the home page when the pop up appears only once and when closed it doesn't appear again when we go to another menu and return to the home page. Is there any coding that I need to add? because I don't understand how to set cookies
this file code theme. js , Am I missing something or is there coding that needs to be added?

mypartnert_0-1714663789509.png

 

PageFly-Amelia
Shopify Partner
626 165 238

This condition ends here, you may need to add else if condition and add modal newsletter popup into 

PageFlyAmelia_0-1714664199203.png

 

Please let me know if it works by giving it a Like or marking it as a solution!


➜ Optimize your Shopify store with PageFly Page Builder (Free plan available) 
➜ Weekly updated Shopify tutorials on YouTube 


All features are available from Free plan. Live Chat Support is available 24/7.

mypartnert
Tourist
10 0 2

thanks for the tips, can you tell me what coding to add if you want the output to be like what I explained above?

PageFly-Amelia
Shopify Partner
626 165 238

Add this code right after end of if condition of your code 

else {
add open modal cod ehere
}

 

PageFlyAmelia_0-1714704384769.png

 

 

Please let me know if it works by giving it a Like or marking it as a solution!


➜ Optimize your Shopify store with PageFly Page Builder (Free plan available) 
➜ Weekly updated Shopify tutorials on YouTube 


All features are available from Free plan. Live Chat Support is available 24/7.

mypartnert
Tourist
10 0 2

Can you help me to create the if condition? because I'm very confused, I hope you can help

conditions where:
1. The pop up appears once on the home page
2. When you go to another menu and return to the home page, the pop up doesn't appear

PageFly-Amelia
Shopify Partner
626 165 238

You can try this 

// Function to set a cookie
function setCookie(cname, cvalue, exdays) {
    var d = new Date();
    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
    var expires = "expires="+d.toUTCString();
    document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}

// Function to check if a cookie exists
function getCookie(cname) {
    var name = cname + "=";
    var decodedCookie = decodeURIComponent(document.cookie);
    var ca = decodedCookie.split(';');
    for(var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') {
            c = c.substring(1);
        }
        if (c.indexOf(name) == 0) {
            return true;
        }
    }
    return false;
}

// Function to display the popup
function displayPopup() {
    if (!getCookie('visitedHomePage')) {
        // Show your popup code here
        setCookie('visitedHomePage', true, 30); // Set the cookie to expire after 30 days
    }
}

// Call the displayPopup function when the page loads
window.onload = function() {
    displayPopup();
};

Please let me know if it works by giving it a Like or marking it as a solution!


➜ Optimize your Shopify store with PageFly Page Builder (Free plan available) 
➜ Weekly updated Shopify tutorials on YouTube 


All features are available from Free plan. Live Chat Support is available 24/7.

PageFly-Amelia
Shopify Partner
626 165 238

You can try this 

 

// Function to set a cookie
function setCookie(cname, cvalue, exdays) {
    var d = new Date();
    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
    var expires = "expires="+d.toUTCString();
    document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}

// Function to check if a cookie exists
function getCookie(cname) {
    var name = cname + "=";
    var decodedCookie = decodeURIComponent(document.cookie);
    var ca = decodedCookie.split(';');
    for(var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') {
            c = c.substring(1);
        }
        if (c.indexOf(name) == 0) {
            return true;
        }
    }
    return false;
}

// Function to display the popup
function displayPopup() {
    if (!getCookie('visitedHomePage')) {
        // Show your popup code here
        setCookie('visitedHomePage', true, 30); // Set the cookie to expire after 30 days
    }
}

// Call the displayPopup function when the page loads
window.onload = function() {
    displayPopup();
};

 

Please let me know if it works by giving it a Like or marking it as a solution!


➜ Optimize your Shopify store with PageFly Page Builder (Free plan available) 
➜ Weekly updated Shopify tutorials on YouTube 


All features are available from Free plan. Live Chat Support is available 24/7.

PageFly-Amelia
Shopify Partner
626 165 238

You can try this 

// Function to set a cookie
function setCookie(cname, cvalue, exdays) {
    var d = new Date();
    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
    var expires = "expires="+d.toUTCString();
    document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}

// Function to check if a cookie exists
function getCookie(cname) {
    var name = cname + "=";
    var decodedCookie = decodeURIComponent(document.cookie);
    var ca = decodedCookie.split(';');
    for(var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') {
            c = c.substring(1);
        }
        if (c.indexOf(name) == 0) {
            return true;
        }
    }
    return false;
}

// Function to display the popup
function displayPopup() {
    if (!getCookie('visitedHomePage')) {
        // Show your popup code here
        setCookie('visitedHomePage', true, 30); // Set the cookie to expire after 30 days
    }
}

// Call the displayPopup function when the page loads
window.onload = function() {
    displayPopup();
};

Please let me know if it works by giving it a Like or marking it as a solution!


➜ Optimize your Shopify store with PageFly Page Builder (Free plan available) 
➜ Weekly updated Shopify tutorials on YouTube 


All features are available from Free plan. Live Chat Support is available 24/7.

PageFly-Amelia
Shopify Partner
626 165 238

This is an accepted solution.

You can try this 

// Function to set a cookie
function setCookie(cname, cvalue, exdays) {
    var d = new Date();
    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
    var expires = "expires="+d.toUTCString();
    document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}

// Function to check if a cookie exists
function getCookie(cname) {
    var name = cname + "=";
    var decodedCookie = decodeURIComponent(document.cookie);
    var ca = decodedCookie.split(';');
    for(var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') {
            c = c.substring(1);
        }
        if (c.indexOf(name) == 0) {
            return true;
        }
    }
    return false;
}

// Function to display the popup
function displayPopup() {
    if (!getCookie('visitedHomePage')) {
        // Show your popup code here
        setCookie('visitedHomePage', true, 30); // Set the cookie to expire after 30 days
    }
}

// Call the displayPopup function when the page loads
window.onload = function() {
    displayPopup();
};

Please let me know if it works by giving it a Like or marking it as a solution!


➜ Optimize your Shopify store with PageFly Page Builder (Free plan available) 
➜ Weekly updated Shopify tutorials on YouTube 


All features are available from Free plan. Live Chat Support is available 24/7.

AbulHasib
Explorer
67 6 1

Hey @mypartnert , you can try our pop-up builder app, " Bevy Design," where you can set up specific pages, such as your homepage. Just copy and paste your homepage URL in the designated option, and that is it. No coding is required. Additionally, To appear the pop-up only once, you can turn off the "display after engagement" feature or set the maximum display as you like. The app is straightforward to use, and we have pre-made templates from which you can create your desired pop-up in minutes. 

 

If you need assistance with setting up your campaign, I'm just a message away. Don't hesitate to reach out.

 

Link of the app - Shopify App Store

For additional information, visit our website: Bevy Design

Specific page.JPGMaximum display.JPG

Customer Success Manager | Bevy Commerce Inc.
Have questions or need assistance? Get in touch: 
Email: abul.hasib@bevycommerce.com
Bevy Support: support@bevycommerce.com
Discover more about Bevy Commerce:
Website: https://bevycommerce.com/
Our Apps: https://apps.shopify.com/partners/bevy-commerce

joe78999
Visitor
1 0 0

to set up home page you have to follow guidelines.Step to step guide is available here.