Please see my comments to the question. You should understand, not quite possible, unless you do authentication.
[EDIT]
If the user is authenticated, it makes more sense.
Still, it would be much better to detect access to your site (log in, log out). Imagine the user loads another page not closing the page you are counting. Is the page in question left or not? You cannot detect activation of the pages, as this is not an event visible to the Web application.
In principle, you can only detect of the user tries to close the page, handling JavaScript event
onunload
and sending HTTP request to the site using Ajax:
http://www.w3schools.com/jsref/event_onunload.asp[
^].
—SA