/    Sign up×
Community /Pin to ProfileBookmark

Collecting Visitor Stats

Hi all,

I want to collate more complex stats on the pages in my site that a user visits.

I want to know what page the user visits, and how long they spend there.

I can already record the page, and the time that page was called. I’m having difficulty with recording the time they leave.

Is there a function that can detect a page closing and if so, how do I keep the server side script “alive” until that page closes?

Note that I’m also considering the alternative approach, which is to send data from the client side using the onClose event in Javascript, but that would not be as efficient.

CTB

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@WebfreakMar 14.2004 — Hi!

To detect what page user visit you can use this function: [code=php]<?php
$referer = getenv("HTTP_REFERER");
?>[/code]
I will check out, if script can write close of window. To keep script alive you can maybe use this meta tag: [CODE]<meta name="doc-class" content="living document">[/CODE]

I will se what i can do ?
Copy linkTweet thisAlerts:
@WebfreakMar 14.2004 — I solve your problem. ? To run a function when user close the page: [CODE]<body onunload="lol()">[/CODE]

When i was searching this i found also something useful for you- here is a [URL=http://javascript.internet.com/page-details/top-alert.html]LINK[/URL]

I hope it works!!! :p
Copy linkTweet thisAlerts:
@chestertbauthorMar 16.2004 — Absolutely outstanding Webfreak.

Thanks.

I'll incorporate anbd report back. Give me a few days.

CTB
Copy linkTweet thisAlerts:
@WebfreakMar 16.2004 — No problem dude :p
×

Success!

Help @chestertb spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...