View on GitHub

Hospitality

Download this project as a .zip file Download this project as a tar.gz file
Welcome to hospitality, nice to meet you.
So glad you could come again, we really hope this solves a problem for you.

hospitality - welcome your guests

Every visitor to your website is unique. You should treat them that way! Hospitality gives you the tools to modify page behavior and copy based on what type of visitor is currently viewing the page. There is default handling for:

It is trivial to implement your own types like free user or paid user.

For a demo, check out the project site

Implementation

Put this at the bottom of your page:

<script src="//d28aj5qi0f6caq.cloudfront.net/dist/hospitality.1.js"></script>
<script>
  hospitality.init({
    visit: {
      new: function() { alert('new-user'); },
      return: function() { alert('return-user'); }
    }
  });
</script>

Config

A new vs. return visit is more than just refreshing the page. To differentiate a return visit, this waits an hour after the first visit to treat the visitor as a return visitor. You can modify the wait via.

hospitality.init({
  wait: 1000 * 60 // wait in ms.
});

By default, users are tracked on a per-domain basis. If you'd like to change that behavior, you can via:

hospitality.init({
    domain: '.mydomain.com'
});

Testing

  1. Startup a web server from the root directory:

    python -m SimpleHTTPServer
    
  2. Go to the test page.