Link to home
Start Free TrialLog in
Avatar of cpwilson
cpwilson

asked on

Website Visitor Tracking Using Coldfusion

Can anyone recommend a good method or possible coding for tracking visitors on a coldfusion-based website. Would want to be able to view number of hits, page views, etc. Would (hopefully) like to be able to code the process into the website itself

Avatar of Scott Fell
Scott Fell
Flag of United States of America image

This is typically not done via a server side language.

Look into Google analytics or https://matomo.org/

It is all done client side.

Alternatively, there are stats packages that ingest your server logs. On windows I used to use smarter stats.

The last option would be creating a database table perhaps with fields for ip,page,url and a timestamp.

if you want SEO info, you will need client side stats
 
Avatar of Charlie Arehart
Charlie Arehart

Adding to Scott's helpful answer, I'll note that perhaps you were wanting to track cfml page requests distinctly from static file requests (html, css, jcls, etc). Of course, GA tracks all requests to the site.

And yet it's not enough to filter GA's results to focus on ".cfm" pages because one can form url's calling CF pages that don't refer to any file extension at all.

All that said, I'll also add that there's no feature built into CF to provide that, though most of the data you need to track a user is tracked in cf's cgi scope. It would be pretty trivial to store that info in a db. (And while cf's client var scope can add a built-in hitcount tracker, I'd not recommend using the client scope/enabling clientmanagement for that "benefit" alone.) 

Finally, I'm not aware of any existing cfml code or app (open source or commercial) that packages this as a solution. As Scott said, most find satisfaction in something like GA, which has its pros and cons. 
Simple way to do this is to use a Web Server, like Apache, which can cookie requests automagically in the request log.

Then parse the request log, usually something like /var/log/apache2/access.log over time to extract data of interest.
David, can you speak to the point I'd raised to Scott's suggestion, where I noted that the url may not have any file extension? I referred to the issue in regard ro GA, but Scott had also mentioned web server log analysis--and my point would apply to both, as they track the incoming url.

If anyone may wonder what I mean, someone could be relying on a default document for a site or folder and specify no filename, or they could be using SES/search engine SAFE urls (as provided for in CF and the Tomcat it runs atop by default) , or they may be using a front-controller pattern, etc.

That said, I agree that either a GA and a web server log approach would be better than nothing. It wasn't clear from the asker if they wanted the info to be tracked and viewable on the fly--whether as viewed by the user or an admin. That would argue against log analysis, of course, but perhaps some costs are higher than the value of their benefits. :-)


ASKER CERTIFIED SOLUTION
Avatar of cpwilson
cpwilson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial