4 ms·
Can I get some feedback on the following idea please: - Maintain an open (but idle) websocket connection on your page to have an accurate real-time visitor inf
by shurcooL 13y ago
Can I get some feedback on the following idea please:
- Maintain an open (but idle) websocket connection on your page to have an accurate real-time visitor information. The websocket should remain open as long as the user doesn't close the tab or navigate away.
What are some cons that prevent everyone from doing so?
- dhimes 13y agoI have many tabs open that I'm not actually "on." I just took a shower and left HN open, for example. Can it detect that the tab is "active" or "focus?" That may help. But I'm not sure this is a problem worth a ton of work. It's, at best, a proxy for measuring things like interest.
- shurcooL 13y agoYeah, as you say, even if it just tells if a tab is open (active or inactive), that's already a good measure of interest. But I think it may be possible to determine if the current tab is open with some javascript, and send that information through the websocket. Edit: what bsimpson said.
- bsimpson 13y agodocument.addEventListener('visibilitychange', onVisibilityChange);
- thezilch 13y ago~50% of visitors don't have websocket support, and there is not, afaik, a free service offering such, and otherwise, it is probably not straightforward enough for the 99% to setup.
- shurcooL 13y agoYou can see a sample in action here [1]. The page should list every single person in the world (whose browser supports websockets) who is currently on that page. You can open multiple tabs and see that whenever you close/navigate away, your corresponding entry will disappear. [1] https://dl.dropboxusercontent.com/u/8554242/live-status.html https://dl.dropboxusercontent.com/u/8554242/live-status.html
- daemon13 13y agoError: TypeError: sock is undefined Ubuntu, Firefox 20.0
- shurcooL 13y agoI just debugged this. The issue is that Firefox doesn't allow insecure websocket connections from https. So either change the url to http://dl.dropboxusercontent.com/u/8554242/live-status.html http://dl.dropboxusercontent.com/u/8554242/live-status.html or override the network.websocket.allowInsecureFromHTTPS setting in about:config to true.
- dangrossman 13y agoEveryone does do so already (though not necessarily with websockets; occasional pings are sufficient and more widely supported). Google Analytics has a real-time dashboard. So do most web analytics platforms these days.
- shurcooL 13y agoHow do you ping a browser? Where can I find more info about this. I figured the real-time dashboard of Google Analytics must be doing something similar, but I don't know what exactly they use.
- dangrossman 13y agoThe browser pings the server. setInterval(function() { $.ajax('http://analytics-site.com/ping?page=' + window.location.href); }, 5000);
- shurcooL 13y agoAh, makes sense, thanks.
- brokentone 13y agoGA realtime does not differ in tracking methodology, it uses the same onload beacon, just like the long-tail reporting.