if you have a database use a table in that, if not use a text file. Then write a script to include in every page. In this included script you'll want to do the following.
1) Check if http referer is somewhere on your site. If it is not then log their IP, date, time and where they came from.
2) log theit IP, date, time and the current page.
You will have to decide what to do with empty http_referers cause that's a pretty common occurance.
With this information you will be able to reconstruct vistors paths through your site including the length of time on pages, except the last page they visited.