View Full Version : How to detect if the user has navigated to a page via BACK button?

01-06-2007, 08:04 PM

Does any of you have any idea on how to detect if the user has navigated to a particular page via BACK button (one or more clicks)?

I am particulary interested in real-time detection strategies. As far as post-processing is concerned I can detect some of the back button clicks by comparing LOG info about the referring page and the page that was viewed before that page, but this is obviously not a full-proof solution. Moreover, I have no means to get this information in real-time, i.e. when the user navigates to the page.

I've been thinking about storing URLs of already visited pages in a cookie, but I'm not interested in knowing whether the page was viewed more than once in a session (cookie information would help in this case), but only if the user has used BACK button to navigate to it.

Any ideas? Suggestions? Comments?


01-08-2007, 09:19 AM
The only way I can think of doing this is with a database log of where the user has been. If the back button is clicked then you will know that way. But this brings up the problem of if the user moved away from your site then hit the back button to return to your site how to handle that.

What do you want a solution like this for? There might be other ways to handle the problem

01-08-2007, 10:02 AM
I need this kind of solution because I try to analyze the user behaviour on my site and it is very useful to know whether the user intentionally clicked on a link to navigate to the page or if he clicked on a back button.

What's your idea with DB log? Isn't that the same as storing information in a cookie (is, cookies are enabled of course :)) - this solution ony gives information is the user has visited the page more than once, but doesn't give any insight into how he navigated to the page.

I have so far come up with two solutions that could give reasonably accurate results when combined. The first one is based on a DOM "feature" causing the refferrer info to be incorrect when BACK button is used - consider the following example:

A Entering URL
B Click on a link A A
C Click on a link B B
D Click on a link C C
C Back button B D
B Back button A C
A Back Button B

This "feature" can actually be used for determining back button click, but is not full proof - for example, one cannot detect the back button in the following scenario: A click B click A back B.

In this case the second solution comes into play - investigation the amount of time the user spent on a page - but it's still not full-proof. :(

01-08-2007, 10:07 AM
I think what you would have to do if you want to track all of this is go ahead and change every link on the site to hit a pass through page. Then you can assume the pass through page has been hit in every circumstance unless the back button has been pressed. I will think about it a bit more though. This is an ugly solution to the problem.

01-08-2007, 10:34 AM
Thanks for the interesting idea. But as you said, it's an "ugly" solution :)