Show a Website Pop-up Only Once with Cookies

Поделиться
HTML-код
  • Опубликовано: 3 авг 2024
  • Learn how to add a website pop-up modal that is only shown to a user once, not every time they refresh the page or change the page. I've made a Webflow clone able for this to make the process even easier: webflow.com/website/Simple-Po...
    📐Template used
    Etro: www.nikolaibain.com/template/...
    All templates: www.nikolaibain.com/templates
    🔗 Links
    Pop-up Cloneable: webflow.com/website/Simple-Po...
    Custom code to use: www.nikolaibain.com/code-snip...
    👋🏻 Where to find me
    Website: nikolaibain.com
    Instagram: / nikolai_bain
    Dribbble: dribbble.com/nikolaibain‍

Комментарии • 55

  • @michaelsausen889
    @michaelsausen889 3 месяца назад +1

    Worked like a charm! I followed the updated instructions in the cloneable and copied the interactions after pasting it into my project. Thank you for this!

  • @vanguard7379
    @vanguard7379 Год назад

    Lol, spent about 2 hours trying to create this from scratch, then found this video. If I owned a bonsai tree, it would have died from lack of care long ago. Thank you sir.

  • @james1327
    @james1327 Год назад +1

    Love the background blur on the windows. Nice touch.

  • @ChaseCharaba
    @ChaseCharaba 2 года назад +1

    Super helpful video! Thank you so much for the custom code. I created a pop-up, and then realized it showed up on every page every time someone clicked on the next page. This fixed that problem!

    • @NikolaiBain
      @NikolaiBain  2 года назад

      Glad to hear I could help! 🤩

  • @hashtagdouchebag
    @hashtagdouchebag Год назад

    Short and sweet! Thanks

  • @alexsialenz
    @alexsialenz 2 года назад +1

    This is cool!

  • @emmanueletti5475
    @emmanueletti5475 Год назад

    Saved me a whole lot of time.

  • @ihsaan7807
    @ihsaan7807 2 года назад +1

    Knowledge bombs. Love it!

  • @hollercountry
    @hollercountry 2 года назад +6

    There is an issue where the class called Pop-up Wrapper and it does not match the javascript to change the display from none to flex. To fix change the class name from Pop-up Wrapper to popup-overlay

    • @jamesmonroedesign
      @jamesmonroedesign 4 месяца назад

      You will need to accomplish this in the "Interactions" as this feature is typically a CSS property. I created a new "Page Load" interaction. Start an animation (name popup ease in) Apply the class provided with the popup. New action / choose "Opacity" NOT Hide show, Set initial state "0." Add another new action / Opacity / Delay 3 sec (or match your delay in provided javascript) / Duration 1 sec / Opacity 100%. Adjust setting as needed. Works great!

  • @OGuaxi
    @OGuaxi Год назад

    Hello Nikolai, awesome video and the code is great! Is there a way to keep showing the banner if the user clicks to go to other pages? The load time and show once is perfect, I only need that tweak :) Thanks a lot!

  • @amandosalinas7171
    @amandosalinas7171 Год назад

    thanks!

  • @justdehaan
    @justdehaan 2 года назад +1

    Great video Nikolai, thank you - btw, what mouse and keyboard do you use? , they both sound amazing

    • @NikolaiBain
      @NikolaiBain  2 года назад

      Haha, sorry if they were a bit loud 😅 Just some cheap ones, I've wanting to get the new Apple Magic Keyboard, but they don't do it in Space Grey. Sad days 😓

  • @TonyMuscolino
    @TonyMuscolino Год назад +2

    I've added an opacity ease out animation but is there a way to ease in so the pop-up isn't abrupt?

  • @connorfinlayson
    @connorfinlayson 2 года назад +1

    10/10

  • @rosemaryblack1494
    @rosemaryblack1494 2 года назад +1

    Hi Nikolai! This was SUPER helpful. Great video. I don't suppose you could do a video, or explain, or if you have a video that explains - how to make a cookie pop-up that would disable this cookie function and all other cookies if the user desired?

    • @NikolaiBain
      @NikolaiBain  2 года назад

      Glad to hear! If you want to do this, best you use the Finsweet Cookies tool, it's super helpful :)

    • @rosemaryblack1494
      @rosemaryblack1494 2 года назад

      @@NikolaiBain Legend - thank you so much, looks like exactly what I need.

  • @TookiePoo2
    @TookiePoo2 4 месяца назад

    Thanks for this! What if I wanted to see the popup every time a user visits the website. Example, if they closed the tab and reopened, I'd want it to show. Is there a simple change to the code to make that happen?

  • @stusmith1201
    @stusmith1201 Год назад +2

    Great Job! I also want to know how to modify the cookie expire value to 24 hours. The value in the code is '1'

    • @amaheer
      @amaheer 5 месяцев назад

      Same here

  • @IszyIzzy
    @IszyIzzy 2 года назад +2

    Thanks a lot for this. My only question is how to add animation to the pop-up to help with easing when it loads in. Help!

    • @mftest7037
      @mftest7037 2 года назад +1

      Hey ISZY-IZZY - did you figure this out? I'm also looking for the same. Thanks!

  • @nickdemore1697
    @nickdemore1697 Год назад

    what if you need the pop up to only pop up for people that have subscribed and continue to pop up otherwise?

  • @ergintamano9356
    @ergintamano9356 2 года назад

    @nikolai bain, What if I want to add the pop-up to select pages of my website and not the entire site? Would adding the code to the page settings make it work? For example, I want to add a pop-up only to blog pages. Should it still work? I tried doing it and it's not working.

    • @NikolaiBain
      @NikolaiBain  2 года назад

      better to add the code to the project settings, but only add the pop up symbol to the pages that you want the pop ups on :) Let me know if this works!

  • @Josiahgoldsmith
    @Josiahgoldsmith Год назад

    Thank you! Any idea why the popup might not be closing when I click the x or anywhere on the screen? It works perfectly other than that

    • @NikolaiBain
      @NikolaiBain  Год назад +1

      Hey Josiah, the pop-up actually doesn't carry over interactions when you copy over symbols, so that might be why, but just re-check the interactions if they are there and see what elements they are triggering :)

  • @jossipierce
    @jossipierce 2 года назад +1

    Hi Nikolai, the popup will run twice when used with the fnsweet cookie opt in banner. After you accept all cookies, the popup loads, then if you refresh, the popup still loads again. If you refresh one more time, the cookie works and keeps the popup from loading in a third time. I have been unsuccessful debugging this.
    Any idea how to solve this?

    • @emilbustos3594
      @emilbustos3594 2 года назад

      It was working before until recently it suddenly have same issues you have encountered. Let me know if you have any updates solving this.

    • @user-uu5hn6zn4t
      @user-uu5hn6zn4t 5 месяцев назад

      I don't know why, but my pop up appears every single time i click on "Home" and i just wanted it to appear once :(((

  • @brandinglab100
    @brandinglab100 Год назад

    I cannot get this pop-up to load. Any suggestions?

  • @carlosr.194
    @carlosr.194 2 года назад +1

    Hi Nikolaibain, I've cloned this at my site, but I can't make it to be displayed only once. Every single time you browse to any different page, it appears again and again, also it does not repect the timing to be appeared at the first time you get in into the web. I check the code, check the same name class, but nothing, it ramain the same. Some clue what could be happing? thanks in advance!

    • @NikolaiBain
      @NikolaiBain  2 года назад

      Hey Carlos! Just tested it again and it's working fine so here's what to check: The custom code is pasted in the section of the project settings, and you're pasting it in the project settings and not just the page settings. Also, delete any transitions if you've applied one to the pop-up, you won't need to add a fade-in animation.
      Best to delete the pop up from your website, delete the classes used, and just re-add it again following the steps :) Let me know if it works this time!

    • @carlosr.194
      @carlosr.194 2 года назад

      @@NikolaiBain Yeah it's working now! thanks a lot mate for your great stuff! Regards

    • @NikolaiBain
      @NikolaiBain  2 года назад

      @@carlosr.194 Great to hear!!

    • @ddappliances6570
      @ddappliances6570 2 года назад

      @@NikolaiBain Hello! I really am having the same problem. I cleaned up the classes and deleted the pop up. I re did all the steps twice and each time I did not even edit the form or any text. I went to my project settings and placed the code into the footer section under "footer code". Saved changed and published. It did not respect the timing for the pop up. What would you suggest that I do next?

    • @fangyihuang4162
      @fangyihuang4162 2 года назад

      @@ddappliances6570 I have the same issue. Have you find a solution yet?

  • @yaaaaaaaa99
    @yaaaaaaaa99 2 года назад +1

    is there an update because its not working

    • @NikolaiBain
      @NikolaiBain  2 года назад

      There is actually! I'm working on a new video for this but you can find the new code + instructions here: www.nikolaibain.com/convert

    • @emilbustos3594
      @emilbustos3594 2 года назад

      @@NikolaiBain Is there any update recently it's not working on my side. I also email you via your website.

    • @JPC4
      @JPC4 Год назад

      @@emilbustos3594 make sure you use the custom code from the link here in the youtube description. the code in the tutorial in webflow is incorrect for some reason.

    • @monkeydgen
      @monkeydgen Год назад

      @@JPC4 yt description code still doesn't work. what to do?

    • @JPC4
      @JPC4 Год назад

      @@monkeydgen do you have any other custom code? it may interfere. I also change my pop up wrapper to be named "pop-up-wrapper" and then changed the custom code to that as well. custom code says "popup-overlay" but should also be called "pop-up-wrapper" or whatever you decide to call your pop up wrapper.

  • @highlander4451
    @highlander4451 2 года назад +2

    Hi guys!
    Use this code if tutorial one does not work.
    Make sure your Pop-Up Wrapper is displayed block.
    var Webflow = Webflow || [];
    Webflow.push(function() {
    // Load cookie library
    $.getScript('cdn.rawgit.com/js-cookie/js-cookie/v2.1.2/src/js.cookie.js', function() {
    // If cookie found (already shown)
    if(Cookies.get('notice') !== undefined) {
    // Hide cookie notice (change jQuery selector to match your own)
    $('#pop-up-wrapper').remove();
    }
    // On button click
    $('#pop-up-wrapper').click(function() {
    // Calculate when you want to display the notice again (change 15 to number of minutes you want)
    var expireTime = new Date(new Date().getTime() + 60000 * 60 * 24 * 60);
    // Set this cookie
    Cookies.set('notice', 'shown', { expires: expireTime });
    });
    });
    });

    • @emilbustos3594
      @emilbustos3594 2 года назад

      Tried this. It's working! Thanks a lot

  • @JoyChien-tm2bn
    @JoyChien-tm2bn Год назад +1

    Hello, I DM'd you on Insta, but I was wondering if there is a way to make that cookie expire? Woudl I replace the expire: 1 w/ say 86400e3 for a day, is it in milliseconds by default?

    • @JoyChien-tm2bn
      @JoyChien-tm2bn Год назад

      Wow, just realised 1 cannot possibly stand for milliseconds. 1 = true? If so, how do I set an expiry for the cookie, so that after X days the cookie will be forgotten?

    • @shivamshetty5558
      @shivamshetty5558 Год назад

      @@JoyChien-tm2bn did you find a solution?