2 Replies Latest reply on Feb 10, 2008 9:06 PM by Irish-Phoenix

    Tracking users, please help

    Irish-Phoenix Level 1
      Hello;
      I wrote a small tracking system for my web site. I am trying to upfrade it to work in CF 8. Here is what I am doing.

      I had this code on the index.cfm page of my site. I am attempting to move it to the Application.cfc file. When I do, it registers in the DB every time the user hits a page or clicks a link. I don't want it to do that. I do want it to tell me when they hit the site, and if I can what page they came in on.

      Here is my code:
      <cfquery name="tracking" datasource="my-DB" dbtype="ODBC">
      INSERT INTO tracking (REMOTE_ADDR, HTTP_USER_AGENT, TRACK_DATE, PageID)
      VALUES('#REMOTE_ADDR#', '#HTTP_USER_AGENT#', #CreateOdbcDateTime(now())#)
      </cfquery>

      My pageID is where I want the information on what page the user came in on to go.
      Is this possible to limit the number of hits counted by the Application.cfm, instead of adding info to the DB everytime they click a link?

      Here is my application.cfc code so far:

      <cfset THIS.name = "my-web">
      <cfset this.sessionManagement="yes">
      <cfset this.clientManagement=true>

      <cffunction name="onApplicationStart" returntype="boolean" output="false">
      <cfset APPLICATION.appStarted = now()>
      <cfreturn true>
      </cffunction>

      <cffunction name="onApplicationEnd" returntype="void" output="false">
      <cfargument name="appScope" required="True">

      <cflog file="#THIS.name#" text="App ended after #dateDiff('n' , ARGUMENTS.appscope.appStarted,now())# minutes.">
      </cffunction>

      <cffunction name="onRequestStart" returntype="boolean" output="true">
      <cfset request.datasource = "my-db">
      <cfset sitePath = " http://www.myweb">

      <!--- this is where I was placing my tracking code --->
      <!--- <cfquery name="tracking" datasource="my-DB" dbtype="ODBC">
      INSERT INTO tracking (REMOTE_ADDR, HTTP_USER_AGENT, TRACK_DATE, PageID)
      VALUES('#REMOTE_ADDR#', '#HTTP_USER_AGENT#', #CreateOdbcDateTime(now())#)
      </cfquery> --->

      <!--- Start True Url Variables --->
      <cfloop list="#removeChars(cgi.path_info,1,len(cgi.script_name))#" delimiters="/" index="variableSet">
      <cfscript>
      variableName = "url." & listGetAt(variableSet,1,'.');
      expression = listGetAt(variableSet,2,'.');
      </cfscript>
      <cfparam name="#variableName#" default="#expression#">
      </cfloop>
      <!--- Finish True Url Variables --->
      <cfreturn true>
      </cffunction>
      </cfcomponent>

      Thank you.

      Phoenix