[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Track hits for specific asset

Posted on 2006-11-06
6
Medium Priority
?
367 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 500 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 500 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

What You Need to Know when Searching for a Webhost Provider
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
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 update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…
Suggested Courses

649 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