Git Product home page Git Product logo

web-session-counter's Introduction

Web Session Counter

What do you do if your boss comes up to you and asks "So how many times must a person come to our app before they give us $500?"

As an engineer you might not care, but this is the stuff that keeps your CEO and growth lead and head of product up at night. A business owner that can answer that ๐Ÿ‘† question reliably is god amongst men.

You can use this repo :)

How to use

$ npm install --save web-session-counter
import WebSessionCounter from 'web-session-counter';

// Do this on user activity
WebSessionCounter.update();

// To get the total count of sessions
const count = WebSessionCounter.count;

.update() is called automatically every time you import WebSessionCounter. I recommend calling .update(), if you have a single page app that doesn't perform a lot of refreshes. Calling .update frequently, ensures your code will correctly detect every 30 minute period of inactivity.

What is a session

We use the same definition as Google Analytics. The tl;dr is that a new session starts after every:

  • 30 minutes of inactivity
  • midnight
  • utm_campaign query change

Enjoy.

web-session-counter's People

Contributors

swizec avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.