Solved

Track hits for specific asset

Posted on 2006-11-06
6
339 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem to echo 6 115
DNS, website, godaddy 6 94
Websocket through haproxy reused connection causes "Not a valid frame" error. 4 125
http to https 3 76
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…
When setting up new project requests for our site, one of the most powerful tools our team has available to use is Axure (http://www.axure.com/). It’s a tool for creating software and web prototypes that can function and interact as if it were the a…
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…

740 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