How Many Users

Currently Viewing This Page:

What is it ?

This is a simple service to show how many users currently viewing/visiting your web page

Usage

Embed this code on your website:


<script src="https://cdn.jsdelivr.net/npm/howmanyusers-js@1.0.0/dist/module/howmanyusers.min.js"></script>
<script>
let howmany = new hmu.HowManyUsers(
    window.location.href, // current page URL you want to track
    {
        listener: function (onlineNum) { // number of users currently viewing the URL
            document.querySelector('#online').innerHTML = onlineNum
        }
    })
howmany.start()
</script>
            

JS API


// Constructor
let howmany = new hmu.HowManyUsers(
    'https://fahri.id/posts/how-to-build-watermelondb-sync-backend-in-elixir/', // full page URL you want to track
    {
        endpointURL: 'ws://10.147.49.246:4000/socket', // endpoint of howmanyusers server. Default: 'wss://ws.howmanyusers.my.id/socket'
        listener: function (onlineNum) {} // callback function to get number of users currently visiting the URL
    }
)

// Instance methods
howmany.start() // start tracking
howmany.stop() // stop tracking
            

Open Source

HowManyUsers - Show how many users are viewing your web page right now. | Product Hunt