It'd probably be easier to parse your web server's log files... all the information you're after is already there.
But, that being said, you could accomplish it your way by doing exactly what you've said. Build an Application.cfm at the
of your server... capture all the information you want... and put it in whatever database(s) you like.
A structure something like:
Code:
-get page name (#GetBaseTemplatePath()#)
-get user information (#CGI.HTTP_USER_AGENT#, #CGI.REMOTE_ADDR, #CLIENT.CFID#, #CLIENT.CFTOKEN#, etc)
-query page log table for hit qty where pagename = name of page
-add one to hit qty
-update page log table where pagename = name of page
-insert into click path table a new row with unique click id (unique primary key), page name, and all user information you need or want
That's about it. No real need for CFLOCK, as you aren't really dealing with Application, Server or Session variables (unless you want to).
Or, better yet, just do the insert into the click path table. With some imaginative querying, you should be able to build a report that shows both views (individual page clicks, and user path) from a single database table... no need to have two.
So just do:
Code:
-get page name (#GetBaseTemplatePath()#)
-get user information (#CGI.HTTP_USER_AGENT#, #CGI.REMOTE_ADDR, #CLIENT.CFID#, #CLIENT.CFTOKEN#, etc)
-insert into click path table a new row with unique click id (unique primary key), page name, date/time, and all user information you need or want
then, in it's simplest form, do a query like:
Code:
<cfquery name="pageviews" ...>
SELECT * FROM clickpath WHERE pagename = '/[URL unfurl="true"]wwwroot/path/file.cfm'[/URL]
</cfquery>
and #pageclicks.RecordCount# now contains the raw number of views for the page
and then do a query like:
Code:
<cfquery name="userpath" ...>
SELECT * FROM clickpath WHERE userid = 1234 ORDER BY timestamp
</cfquery>
and the result set "userpath" now contains a full blow-by-blow list of how user 1234 traveled through your site.
Same table.
Hope it helps,
-Carl