Solved

Track hits for specific asset

Posted on 2006-11-06
6
312 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
6 Comments
 
LVL 7

Accepted Solution

by:
aseusainc earned 125 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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 24

Assisted Solution

by:dgrafx
dgrafx earned 125 total points
Comment Utility
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now