Track Web Page visits in CFM

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ndeeley
    New Member
    • Mar 2007
    • 139

    Track Web Page visits in CFM

    Hello,

    I have never done any web page tracking in CFM, and now I have been asked to.

    I can create a table in my database to hold the information but as a newbie can someone tell me how I start? An overview would be great as I really don't have a clue beyond creating a table to hold whatever data (and I think I know how to create the query to retrieve it).

    Cheers!
    Neil
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Depends exactly what you want to track. Unique visitors, page visits, site visits, etc.

    Comment

    • ndeeley
      New Member
      • Mar 2007
      • 139

      #3
      Hi acoder,

      It's an intranet site, so all I need to store is the username, date and time and page name. Basically its to justify the existence of the website if noone is using it!

      Thanks
      Neil

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        So, you can create a table with 3 fields (plus one for ID): user name, a date/time field and page name field.

        In either application.cfm or onrequestend.cf m, add a bit of code which inserts a record in this table: GetAuthUser() for the user name, now() for the date/time and cgi.script_name for page name.

        Comment

        • ndeeley
          New Member
          • Mar 2007
          • 139

          #5
          Thanks acoder. I also needed it to track normal HTML pages so what I did was create a small iframe:

          <iframe src="http://marlin/engeastl/scripts/RepairWorkshops/tracker.cfm?nam e=RWD_HomePage" height="1px" width="1px" frameborder="0" >

          And used the tracker.cfm page to add the info to the database.

          Not Strict HTML compliant, but its works!

          Cheers
          Neil

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            You can serve HTML pages using Coldfusion too. If you want to pass validation with iframes, either use Transitional, or use JavaScript to generate the iframe onload.

            Comment

            • ndeeley
              New Member
              • Mar 2007
              • 139

              #7
              Originally posted by acoder
              You can serve HTML pages using Coldfusion too. If you want to pass validation with iframes, either use Transitional, or use JavaScript to generate the iframe onload.
              Good idea!

              I'll give that a try as well. Thanks for your help.

              Neil

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                No problem :)

                Comment

                • ndeeley
                  New Member
                  • Mar 2007
                  • 139

                  #9
                  Originally posted by acoder
                  No problem :)
                  Also acoder, do you know how I can grab the url of the page I'm tracking, to store it? I have been looking at #CGI.REFERER# but I can't get it to work!

                  Thanks
                  Neil

                  Comment

                  • acoder
                    Recognized Expert MVP
                    • Nov 2006
                    • 16032

                    #10
                    Try #cgi.script_nam e# or do you mean the page that refers to the current one?

                    Comment

                    Working...