How can I show the number of visitors online at any page load via Google analytics?
E.g., when a visitor loads the page somewhere it will say "58 Visitors Online".
While many marketers believe it's out of the question to track individual users in Google Analytics, it's not impossible. If your application or website has a login authentication system, then it is possible to track users in Google Analytics with it's User ID tracking feature.
This cannot be done in analytics; however, you can do this yourself by having a ping-back function in JavaScript, where every N seconds, you kick-off a "heart-beat" request to your server, using XHR, and include some sort of unique ID. When some amount of time (more than N seconds) passes without a heart-beat from a given ID, you can assume that the user is no longer actively on that site. Moreover, you can combine this with the visibility APIs to show only the set of users who are actively viewing the page (as opposed to users who have the page open but in a background tab).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With