Forum Moderators: open

Message Too Old, No Replies

Need to know when user browses away

But how...

         

Zaphod Beeblebrox

1:13 pm on Jun 15, 2004 (gmt 0)

10+ Year Member



Hi everyone,

I'm asked by a client to develop a script that determines when a user actually browses away from a page. He wants to determine how long exactly someone is watching his webcam sites.

Problem is, of course, that his webcam pages are on another server, and they cannot be modified.

So, from my server I wanted to open a page with a frameset, in which the remote page is loaded. I thought I could use the onUnload event in some way to call another page which updates the necessary information, but I haven't managed to do that just yet.

Also, I want to avoid using a popup for the reasons that they're irritating, and many people have them blocked.

If anyone has any ideas, I'd love to hear them!

Peter

BlobFisk

1:16 pm on Jun 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmmmm... This is information that can be got from the webserver logs. This, I'd say, is the best source.

You could put together a server side script that accesses the visitor session information and calculates a value - but this is very hit and miss...

HTH

dcrombie

2:42 pm on Jun 15, 2004 (gmt 0)



The server logs only tell you when a page or file is opened - not when it's closed. That's because the browser only talks to the server _while_ it's requesting the page. If you need to gather information about what the user is doing while the page is open then you need to:

a) use some kind of real-time application such as Java or ActiveX that constantly reports back to the web server; or
b) use the onUnload (or similar) event to record (eg. via a pop-up) when the page is closed, but realise that this won't work in all browsers.

DrDoc

2:45 pm on Jun 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



onunload would work, if it weren't for the fact that you have no control over the other pages. Using a frameset will not help, since JavaScript cannot access the DOM of pages on a different domain. So, server logs may be your best bet... Or the popups that you don't want to use...

Rambo Tribble

3:20 pm on Jun 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Perhaps you could use the onload and onunload events to trigger loading two different, minimal, hidden images and time the interval between accesses.

Zaphod Beeblebrox

3:37 pm on Jun 15, 2004 (gmt 0)

10+ Year Member



I've tried changing the document in the onUnload event (using an iframe), but that seems to undo the unload, causing the browser to remain on the page instead of going where the user wanted to go.

I found that somewhat undesirable... ;-)

Rambo Tribble

10:39 pm on Jun 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How about initiating a counter with onload, then using onunload to submit a form with the counter value as part of the URL's get data? That might not gum the works.

DrDoc

11:15 pm on Jun 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Problem is, of course, that his webcam pages are on another server, and they cannot be modified.

So, it has to be a solution that does not require page modification. And, those are still pages that the client is interested in "timing"...

Rambo Tribble

2:15 am on Jun 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I was assuming the second-party page would be in an iframe and the whole page would unload to trigger the event. If that isn't the case, I suppose a page from the first party would have to be loaded into the iframe as a wrapper to the s-p page. That way the timer would be part of the wrapper.

Zaphod Beeblebrox

9:48 am on Jun 16, 2004 (gmt 0)

10+ Year Member



Yes, I'm starting to think it can't be done. I doubt I'll be able to access the other server's logfiles, since I won't even know in advance which ones they will use, and how many they will use.

A slight explanation might be handy: they're looking for a load-balancing script as a cheap alternative.

Zaphod Beeblebrox

12:17 pm on Jun 16, 2004 (gmt 0)

10+ Year Member



I believe I've got it!

The main page contains two frames. The first one is tiny and contains an ASP page that refreshes every minute (and thus keeps track of activity), and the second one contains the actual content from the second server...

DrDoc

2:44 pm on Jun 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That would work...