Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / April 2008

Tip: Looking for answers? Try searching our database.

How do I detect a user leaving the site?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andy - 28 Apr 2008 16:25 GMT
As per the question really.

Not trying to stop them leaving, but just detect WHEN they leave the site
Cowboy (Gregory A. Beamer) - 28 Apr 2008 16:49 GMT
You can set up JavaScript on a page, but you will have to make it elaborate
enough to distinguish page unload from page unload to another site. This is
how sites that try to get you to download trojans work, popping up a modal
popup when the user leaves a page, except they do it on any unload.

Storing that they have left will require an AJAX like solution, as you will
have to have the JavaScript contact the server.

Signature

Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************************************************

| Think outside the box!

*************************************************
> As per the question really.
>
> Not trying to stop them leaving, but just detect WHEN they leave the site
George Ter-Saakov - 28 Apr 2008 16:50 GMT
Due to disconnected nature of the Web applications it's a bit hard (and
always not reliable).

First you need to define for yourself "exit time".
Then you need to define precision. For example "We need 1 hour timeframe".
Meaning that if user left 8:50 and we detected it by 9:00 then we fine... .
-------------------------------------------------
Here are some thing you can test if they going to work for you.

1. You can get last time user has requested anything from your site. And
call it your "exit time". Basically update exit time everytime user had send
a request to aspx. At the end when user closes the browser you will have
last "exit time".

Problem: if user requested page "article.aspx" and then sitting there
reading it for 30 minutes and then closes browser you will have exit time 30
minutes before user actually closed the browser...

But this comes does to definition of what is "exit time".

2. To reduce lag time specified in #1 you can have a JavaScript that would
refresh a tiny image on your page every minute. then if user looked at your
page for 30 minutes you will have exit time within one minute range...

But this comes down to the precision... And obviously will have a problem if
JavaScript is disabled.

Check out this on how to do that with an image...
http://www.codeproject.com/KB/aspnet/SessionForever.aspx

----------------------------------------------------

George.

> As per the question really.
>
> Not trying to stop them leaving, but just detect WHEN they leave the site
bruce barker - 28 Apr 2008 16:54 GMT
there is no surefire way. the most common is a lightweight  ajax call on page
unload (which will fire on every page referesh), then run a timer on the
server to detect that the user did not return to the site. you can also use a
session timeout for this (20 minutes of no site hits).  

-- bruce (sqlwork.com)

> As per the question really.
>
> Not trying to stop them leaving, but just detect WHEN they leave the site
Mark Rae [MVP] - 28 Apr 2008 17:10 GMT
> Not trying to stop them leaving, but just detect WHEN they leave the site

As per the other replies, there is no 100% reliable way of doing this...

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Cowboy (Gregory A. Beamer) - 28 Apr 2008 19:27 GMT
Client side JavaScript is the most surefire, but one can easily circumvent
it by killing the browser. LOL ;-)

Signature

Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************************************************

| Think outside the box!

*************************************************

>> Not trying to stop them leaving, but just detect WHEN they leave the site
>
> As per the other replies, there is no 100% reliable way of doing this...

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.