General Question

Ranimi23's avatar

How can I implement in my small web site company how many members are observing each page right now?

Asked by Ranimi23 (1914points) June 22nd, 2010

I love the idea to see in Real-Time how many members of my company viewing each page on the site. How can I implement this? I know when user is starting to observe in the page loading, but I don’t know when he his leaving the page or closing the browser.

Any idea?

Observing members: 0 Composing members: 0

5 Answers

arpinum's avatar

I’ve seem people use the window.onbeforeunload event to do this. A common problem with this method is a script not finishing in time. You can use the event to open a new web page that runs a script, but never sends display information. That way you don’t have to worry about your function being killed.

netgrrl's avatar

Check out a website called If you can add the code to your website, you can see real-time stats on visitors & page views. It’s free for websites with less than 30,000 hits a month.

anartist's avatar

@netgrrl Thanks for the tip!

phaedryx's avatar

That’s what fluther does with “observing members” and “composing members” (right below the question section. Take a look at the source for this page. This script: is updating both of them. You can see where it is actually setting the elements at the bottom:

$(‘listeners’).innerHTML = response.num_listeners;
$(‘composers’).innerHTML = response.num_composers;

Kodewrita's avatar

use the setInterval() method to poll a script. on successful arrival of the message at the server, the script updates a field.

another setInterval loop checks to find out the current value of the viewing field on the server. You can then send that back to the client. On arrival, the value is used to alter the DOM

Answer this question




to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
Knowledge Networking @ Fluther