Counting specific file downloads

Results 1 to 2 of 2

Thread: Counting specific file downloads

  1. #1
    Join Date
    Dec 1969

    Default Counting specific file downloads

    Hi<BR><BR>For a number of days now I have had an ASP script working to count the downloads of our companies PDF documents. This is in conjunction with a MSAccess database.<BR><BR>We also have DeepMetrix&#039;s web stats software installed on the server which also shows the number of times a file is downloaded.<BR><BR>I am more inclined to believe the DeepMetrix software values for the file downloads as it works directly with the server log files but am trying to get the ASP script to work correctly as this would allow me to customise the count figure as I would like for the people concerned so they don&#039;t have to access the Deepmetrix stats.<BR><BR>ASP Results can be seen at:<BR><BR><BR>My problem is that in comparing the ASP scripts count of the number of downloads versus the Deepmextrix values that they differ widely and was wondering if anyone would know why ?<BR><BR>My script basically requires that when the user clicks the link for a PDF download that it goes through the script which counts the click and then forwards the visitor onto the actual pdf.<BR><BR>All works on a querystring from the original page EG:<BR><BR>which is sent to the page count_form.asp (Code at bottom)<BR><BR>Any help in this regard is appreciated.<BR>JasonC<BR><BR>P.S.Extra info follows below<BR><BR>The compared values are as follows:<BR><BR>Date: 07 - 12 - 2001 (Today)<BR>-----------------------------------------------<BR>PDF &#124 DeepMetrix &#124 ASP &#124<BR>-----------------------------------------------<BR>WorkCanada_2002.pdf &#124 100 &#124 87 &#124<BR>KAMP_Forms_2002.pdf &#124 47 &#124 52 &#124<BR>WorkCanada_2002.pdf &#124 75 &#124 2 &#124<BR>-----------------------------------------------<BR><BR>Date: 06 - 12 - 2001<BR>-----------------------------------------------<BR>PDF &#124 DeepMetrix &#124 ASP &#124<BR>-----------------------------------------------<BR>WorkCanada_2002.pdf &#124 261 &#124 186 &#124<BR>KAMP_Forms_2002.pdf &#124 124 &#124 53 &#124<BR>WorkCanada_2002.pdf &#124 68 &#124 36 &#124<BR>-----------------------------------------------<BR><BR>ASP Co8unt that counts the downloads is as follows if needed:<BR>------------------------------------------------------------<BR>&#060;%<BR>&#039;// SCRIPT FUNCTION: This script runs a lookup to see if the application form been requested<BR>&#039;// has been downloaded previously today. If not it adds a count of 1 for that form with todays date<BR>&#039;// and then forwards user onto the actual form for download.<BR>&#039;// If the form has already been downloaded one or more times today the script determines <BR>&#039;// the correct row id and increments the count for that form by one.<BR>&#039;// <BR>&#039;// Standard ODBC connections using SQL strings and a DSNLess connection for speed and reliability.<BR><BR> Dim currentDate<BR> Dim formToPass<BR> Dim previousCount<BR> Dim newCount<BR> Dim redirURL<BR> Dim commonURL<BR> Dim connString<BR> Dim objConn<BR> Dim objCmd<BR> Dim objRS<BR> Dim sql<BR> Dim id<BR> <BR> commonURL = "/forms/"<BR> <BR> connString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & Server.Mappath("/_db/uk/application_downloads_count.mdb") & ""<BR> <BR> formToPass = Trim(Request.QueryString("uri"))<BR> currentDate = CStr(date)<BR> <BR> redirURL = commonURL & formToPass<BR> <BR> Set objCmd = Server.CreateObject("ADODB.Command")<BR> Set objConn = Server.CreateObject("ADODB.Connection")<BR> Set objRS = Server.CreateObject("ADODB.RecordSet")<BR> <BR> sql = "SELECT * FROM form_counts WHERE form_taken = &#039;" & formToPass & "&#039; AND dateadded = &#039;" & CStr(date) & "&#039;"<BR><BR> objConn.Open connString<BR> objCmd.ActiveConnection = objConn<BR> Set objRS = objConn.Execute(sql)<BR> <BR> <BR> <BR> If(objRS.EOF or objRS.BOF)Then<BR> &#039;If there are no records create a new one for today for this particular form.<BR> Set objRS = Nothing<BR> sql = "INSERT INTO form_counts (dateadded,form_taken,form_counter) VALUES(&#039;" & currentDate & "&#039;,&#039;" & formToPass & "&#039;,1)"<BR><BR> objConn.Execute(sql)<BR> <BR> Set objConn = Nothing<BR> Set objCmd = Nothing<BR> <BR> Response.Redirect redirURL<BR> Else<BR> &#039;Record for this form for today exists therefore update table.<BR> id = objRS("id")<BR> previousCount = CInt(objRS("form_counter"))<BR> newCount = CInt(previousCount) + 1<BR> newCount = newCount<BR> <BR> sql = "UPDATE form_counts SET form_counter = " & newCount & " WHERE (id = " & id & ")"<BR> objConn.Execute(sql)<BR> <BR> Set objConn = Nothing<BR> Set objCmd = Nothing<BR> Set objRS = Nothing<BR> Response.Redirect redirURL<BR> End If<BR>%&#062;<BR>------------------------------------------------------------

  2. #2
    Join Date
    Dec 1969

    Default My only comment

    is that while your script workds correctly people may be accessing the files without going thru the interface. Especially once they get the correct url for the file they can keep going directly to the file which probably explains why the DeepMetrix counts are generally higher. As for the one lower count possibly it&#039;s due to partial download not being counted or something. You could take the docs outside the website and use the adostream object to read and do a binary write to serve to the client. This would prevent the user going directly to the files but would probably kill the DeepMetrix stats. I&#039;d test a file that only you can get to (ie only show link for admin) and download a few times to test your results VS DeepMetrix&#039;s.

Posting Permissions

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