Skip to content

An extensible JavaScript plugin for site-builders like Squarespace to easily create an age-gate that sets a cookie for free.

License

Notifications You must be signed in to change notification settings

nicknish/agegate-popup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AgeGate Popup

An extensible JavaScript plugin for site-builders like Squarespace to easily create an age-gate for free.

Example of Age Gate

Usage

For Squarespace or other site-builder usage, see below.

  1. Add script to your website JavaScript.
  2. On page ready, call new Agegate, passing in your options:
new Agegate({
    cancelUrl: 'https://nicknish.co'
})

Squarespace

  1. Go to Settings.
  2. Under the Website category, find Advanced.
  3. Go to Code Injection. This is where you can add custom scripts to your Squarespace website.
  4. Scroll to Footer.
  5. Click this link, copy the contents of the script, then paste it between two <script> HTML tags.
<script>
  // POPUP.MIN.JS SCRIPT GOES HERE
</script>
  1. Then, before the </script> tag, right after the code you copied, add this:
<script>
// POPUP.MIN.JS SCRIPT GOES HERE

(function(window) {
  function ready(fn) {
    if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading"){
      fn();
    } else {
      document.addEventListener('DOMContentLoaded', fn);
    }
  }
  
  ready(function() {
    new Agegate({
      cancelUrl: 'https://nicknish.co' // This is where your user will be taken if they do not agree to the popup
    });
  })
}(window));
</script>

To Do

  1. Create tutorial to add this to your Squarespace or site-builder website.
  2. Add note about adding CSS from popup.css.
  3. Update demo to be able to reset the popup cookie.
  4. Add notes about dependencies, file size, and supported browsers.
  5. Add Webpack to handle a lot of the heavy-loading and maintenance of this repo.

Bugs or Having trouble?

Create a new issue here.

About

An extensible JavaScript plugin for site-builders like Squarespace to easily create an age-gate that sets a cookie for free.

Resources

License

Stars

Watchers

Forks

Packages

No packages published