Solved

Track hits for specific asset

Posted on 2006-11-06
6
342 Views
Last Modified: 2013-12-24
Hi, I need to track a specific asset (logo.gif) and report on how many times and from whom this asset is called from the server (server 2003 using IIS v6). What is the log file I need to audit and how does coldfusion monitor that?
0
Comment
Question by:patGRFXS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 7

Accepted Solution

by:
aseusainc earned 125 total points
ID: 17884998
You can specify the log file within IIS itself.  Generally, I think it's default in something like C:\windows\system32\logs\w3svc.

Things like webtrends make auditing this a breeze.  Otherwise you could easily write an app in CF to parse out the data.

As far as CF tracking hits, I dont know, never really messed w/ CF logs other than to troubleshoot.
0
 

Expert Comment

by:Klainn
ID: 17887882
Is logo.gif something that people will be clicking on to bring up?

If so you could do something like ..

<a href="hit.cfm"><img src="logo.gif></a>

hit.cfm

<cfquery datasource="#dsn#">
UPDATE LOGO_HIT_COUNTER
SET HIT_COUNT = HIT_COUNT + 1
</cfquery>
<script language="JavaScript" type="text/javascript">
<!--
  window.opener = self;
  window.close();
// -->
</script>


I use this quite a bit. Or if logo.gif isn't something that's clicked on, you could just create hit.cfm and call it on the body of the page holding logo.gif. <body onLoad="http://#CGI.SERVER_NAME#/hit.cfm">
0
 

Author Comment

by:patGRFXS
ID: 17951536
It turns out that the script above from Klainn will not work in this case becouse I am not tracking when the image is being clicked on. I need to monitor the log files and report when a particular image file is called by an outside IP. I know the IP.
0
 
LVL 25

Assisted Solution

by:dgrafx
dgrafx earned 125 total points
ID: 18014158
Hi,
I believe there is a misunderstanding on how to track hits on a specific asset.
forget about tracking logo.gif or parsing log files.
on your page that you want to track you'd put:
<cfset str="ip=#cgi.remote_addr#">
<cfif StructKeyExists(Cookie,"Username")>
<cfset str=ListAppend(str,"Username=#Cookie.Username#","&")>
</cfif>
<cfif StructKeyExists(Session,"WhatEver")>
<cfset str=ListAppend(str,"Whatever=#Session.WhatEver#","&")>
</cfif>
You can put whatever you want to track
the code is simply saying if there is a cookie.username then tack it on
<img src="http://www.yourdomain.com/tracking.cfm?#str#" style="display:none;">
note:
This img tag needs to be within a <cfoutput></cfoutput>
the http of the img tag url will be https if this is a secure server

Then here is an example tracking.cfm
<cfset str=replace(URLDecode(cgi.query_string)," ","","all")>
<cfloop list="#str#" index="ii" delimiters="&">
      <cfset "#trim(listfirst(ii,'='))#"=trim(listlast(ii,'='))>      
</cfloop>
Only you know what you want to track - so I'm just supposing ip
<cfquery datasource="#request.datasource#">
      Insert Into Tracking WITH (tablock)
      (IP,str)
      Values
      ('#trim(IP)#','#trim(str)#')
</cfquery>
be sure you've setup a primary key that is an auto incrementing integer
and if you want a date field set it's default value to (getdate()) instead of inserting date with your query.
I'm inserting 'str' to an ntext field in the table also just for reference

you now have a database record that you can write a report on to view "hits" for a resource

now - with all that said (I realize it may be more than you wanted) you say you know the ip.
does that mean you are looking for just one ip?
write the code into your report to show hits based on this ip
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
.htaccess rewrite url with querystring problem 13 123
AWS New EC2 Instance and EBS Storage 2 101
WEB Farm 6 85
move expression web site to a new server 13 106
Now that Expression Web 4.0 (http://www.microsoft.com/expression/products/Upgrade.aspx) is free if you buy or have the full version of Expression Web 3.0, now is the best time to  migrate from FrontPage to Expression Web (http://www.frontpage-to-exp…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
The purpose of this video is to demonstrate how to create a Printer Friendly PDF on a WordPress Page. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome Screenshot” Google Chrome Extension, and SmallPDF.com Log…
The purpose of this video is to demonstrate how to insert an Iframe into WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Open Page or Post…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question