Another very cool thing about storing stats in the database is that I
now have links on each page pointing to "Page Stats".  That gives me a
graph report of how many times that page has been hit in the last month
and a list of all the referring pages.

I even setup two extra fields called "key_name" and "key_data".  That
way If I have the URLs:

http://www.secretagents.com/products/index.cfm?fuseaction=product&product_id=6
http://www.secretagents.com/products/index.cfm?fuseaction=product&product_id=5

Notice how they both have the same fuseaction.  Well it also stores:
key_name="product_id"
and
key_name="6"  or   key_name="5"  respectively.

That way the same fuseaction can be logged as different pages... because
they are.  

I've still got a few tweaks I want to add and I'll release the code for
others to play with.

Steve

Steve Nelson wrote:
> 
> I've upgraded my stats tool quite a bit.  One thing that I'm seeing that
> is VERY cool about storing the stats in the database is being able to
> store a #client.user_id# (i.e. a primary key to a logged in user's
> record).
> 
> Get this.... I have two scheduled tasks, one that dumps the application
> scoped query to the database, and a second that runs this code:
> 
> <cfquery name="nonnull" datasource="#request.logdsn#">
>         select distinct user_id,token
>                 from page_logs
>                         where user_id is not null
>                         and token in (select distinct token from page_logs where 
>user_id is
> null)
> </cfquery>
> 
> <cfloop query="nonnull">
>         <cfquery name="updatenull" datasource="#request.logdsn#">
>                 update page_logs
>                         set user_id=#user_id#
>                         where token='#token#'
>                         and user_id is null
>         </cfquery>
> </cfloop>
> 
> Basically this code does this:
> 
> Page                            User_id         token
> /index.cfm?fuseaction=1         NULL            11202:383839
> /index.cfm?fuseaction=2         NULL            11202:383839
> /index.cfm?fuseaction=3         205             11202:383839
> 
> And changes it to this:
> 
> Page                            User_id         token
> /index.cfm?fuseaction=1         205             11202:383839
> /index.cfm?fuseaction=2         205             11202:383839
> /index.cfm?fuseaction=3         205             11202:383839
> 
> User_id is the foreign key to my "users" table, so now I can view the
> trail of individual users.  This has about a zillion and one uses.
> 
> Steve Nelson
> Online Web Development Training:
> http://www.SecretAgents.com/training
> (804) 825-6093
> 
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to