Jump to content

7.1 promotion pop-up only disappears after subscribed

Recommended Posts

Hello all,

maybe someone can help me with this:

Is it possible with 7.1 that the promotion pop up only disappears when the user has subscribed via email.  Something like a lock page. That the user only gets access to a page if he has subscribed via email.

Thanks for you help.

Best, Dake

Link to comment
  • 2 years later...
  • Replies 3
  • Views 1.3k
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Did you ever find a solution for this?  I currently have the pop-up, but it disappears if someone leaves the page and comes back or refreshes the page.  I've injected this code into the header of the page to solve that, however this causes the pop-up to keep coming up even if the person enters their email.

<script>
  window.localStorage.setItem('test', '0');
  window.localStorage.setItem('squarespace-popup-overlay', '0');
</script>

I also have the following settings, but the next day feature will not help if the person leaves the page and comes back or refreshes the page that same day.

image.png.8bf55ebf54a03ad3dbba057e826213ee.png

 

 

Link to comment

Not sure if something to this effect can be injected into the header of page. Would need to update specific terms to function within squarespace depending on language they use for subscribed, emailForm etc.

<script>
  // Function to set the subscription status in localStorage
  function setSubscriptionStatus() {
    window.localStorage.setItem('subscribed', '1');
  }

  // Check if the user has already subscribed
  function hasSubscribed() {
    return window.localStorage.getItem('subscribed') === '1';
  }

  document.addEventListener('DOMContentLoaded', function() {
    var promotionPopUp = document.querySelector('.squarespace-popup-overlay');

    // Check if the pop-up should be shown and if the user hasn't subscribed yet
    if (!hasSubscribed()) {
      promotionPopUp.style.display = 'block';
    }

    // Find the email form inside the pop-up
    var emailForm = promotionPopUp.querySelector('form');

    // Add event listener to the form submission
    emailForm.addEventListener('submit', function(event) {
      event.preventDefault(); // Prevent the form from submitting normally

      // Your additional logic to handle form submission (e.g., sending the email address to your email list)

      // Set the subscription status in localStorage after successful submission
      setSubscriptionStatus();

      // Hide the pop-up after subscription
      promotionPopUp.style.display = 'none';
    });
  });
</script>

 

Link to comment
  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.