SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Tracking user downloads?

    OK Guys...

    Some of you may remember this thread I posted from a month or so ago:
    http://www.sitepointforums.com/showt...threadid=54507

    My boss has come to me and now says she wants to gather more information about user habits, specifically an average of "downloads per user" and more importantly, relating what a user downloads in relation to the other coupons.

    Currently, I'm only gathering how many times each section is clicked on, and how many times each coupon is downloaded but I'm not relating any of that to a specific user. You can see the stats here:
    http://coupons.nashvillecvb.com/tracking.cfm

    So my question is...how much more complicated is her request than what I already have? I'm not setting any sort of session or cookie right now. I find this not a little bit exciting because I know that I'll likely have to use ONE of these methods to gather this information and this will be my first time using either of them.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  2. #2
    SitePoint Addict ownersite's Avatar
    Join Date
    Jul 2001
    Posts
    222
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    creole,

    Check out this article about session management in CF that I found helpful when I first came upon it...

    http://www.itworld.com/AppDev/1650/U...08webmasteraf/
    F150online- 102,000 users strong and growing...
    Ownersite.com
    - tools to enhance vehicle ownership

  3. #3
    SitePoint Guru nagrom's Avatar
    Join Date
    Jul 2001
    Location
    Western CT, USA
    Posts
    803
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the safest method would be to make a login screen, that connects to a DB and logs each user's activities there. this would be a place to use sessions, so you can keep track of whose logged in, and store their corresponding DB id without constantly having to retrieve it for every write to the DB.

    or, you could just drop a cookie with the data your interested in, and read and rewrite it when appropriate. since you'll probably have multiple fields, you can either set the cookie as a list, and keep track of the order, or if you want to get fancy store the data in an array or structure, and serialize it using CFWDDX before you write the cookie (and deserialize when you read it back in).

    you'd want to use a structure or array if you do it with sessions too, instead of setting tons of session variables. don't forget the default for sessions is to use cookies to--what happens is the server drops two cookies onto the client that key that client to a session id in the server's memory.

    ok? wise-guy?
    i'd come to nashville and kick *your* butt, but i know i'd immediately be overrun by all your buddies, with their dukes-of-hazard cars and retractble license plates.

  4. #4
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Let me ask this...

    How difficult is this? Is this pretty high-level stuff? Is it realistically something that I could program?
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  5. #5
    SitePoint Guru nagrom's Avatar
    Join Date
    Jul 2001
    Location
    Western CT, USA
    Posts
    803
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    naw, cmon! piece of cake!
    really, i think you can handle it.
    i would do the list as a cookie method first. you could then move that concept to a DB if it got out of hand, or you needed to relate to another table or something.

  6. #6
    SitePoint Member
    Join Date
    May 2001
    Location
    vancouver
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm going to assume that your site does not have a login page. If it does then, you can set a cookie or state management after the login so you'll know WHO the user is.

    if you just want to get stats per user, as opposed to relating stats to a user who's details you know, all you need to do is this.

    1. Write a cookie script in your application.cfm file.

    <!--- give the user a Unique ID, if they do not already have one --->
    <cfif not isdefined("cookie.userID")>
    <cfset cookie.usrID=createUUID()>
    </cfif>

    2. Then on any page that has a download or any other action you want to track, you would do something like

    <cfif isdefined("cookie.userID")>
    <cfquery datasource="dns" name="updateStat">
    insert into downloadstats(usrID,dateaccessed,file)
    values('#cookie.usr_id#',#createodbcdatetime(now())#,'download.pdf')
    </cfquery>
    </cfif>

    All this does is add a new record each time a file is downloaded. It can be customized to track anything. You just record the filename that was download and use the ID that you stored earlier in the cookie.

    Then when you write a script to report on the data you can look for multiple instances of the userID to determin how many files each user has downloaded.

    Note, that this will only give you general usage stats and will not be able to tell you the names or details of any of your users. But, if at a later date, you decide to ask your users to sign up, you could then check for the cookie after they sign up and assign them the ID they have already been using without knowing it. Then all of the orphaned records would be related to your new user.

    Did that make sense?
    Brook Davies
    www.logiforms.com
    "add feature rich database backed forms to your site with no programming"

  7. #7
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Believe it or not, it actually did make sense. Let me ask a few questions for clarification though.

    -= createUUID() is a built in CF function?

    -= I don't really care WHO the user is, just that my boss wants to find out their habits...without relating that information to the user themself.

    -= So the DB would look like this:
    UserID
    Dateaccessed
    File
    ?

    -= Would file contain a list of every file that the user downloads or would it contain a single file and each time they grab a NEW file, it would simply make a new record?
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  8. #8
    SitePoint Member
    Join Date
    May 2001
    Location
    vancouver
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    CreateUUID() is a CF function which generates a Unique ID. The string is a bit long though and it is not a number, it is a string. I think if we wany to keep this thing fast, we will use an integer (a smaller one at that.), try this instead of createUUID()

    <cfset NewuserID="#randrange(1,1000)##randrange(1,10)##dateformat(createodbcdatetime(now()),"mmddyymm")#">

    This will create a number like 945705070205 instead of the UUID string that looks like this 9B3894F3-4849-4ED8-A13F1579803A62D0.

    This will allow you to use an integer field which should speed inserts and help latr when you go to display the data.

    Back to the DB:

    This is a rather simple implementation, but it will work.

    The DB would have UsrID (the cookie values), dateaccessed (date + time stamp), and the something like a field named request. Request would hole the name of the file requested. You will end up with 1 record for every download.

    One of the alternatives is to store only the total number of downloads. But if you did this then you would need to retrieve the current total, increment it and write it back to the DB. This would cost you and Update and an Insert as opposed to just an update.



    Table View:
    UserID | INT
    Dateaccessed | DATETIME
    Request | VARCHAR (100)

    Good luck with it!
    Brook Davies
    www.logiforms.com
    "add feature rich database backed forms to your site with no programming"

  9. #9
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your input. You using mySQL for your backend?
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •