Connecting Tech Pros Worldwide Help | Site Map

Track Web Page visits in CFM

Member
 
Join Date: Mar 2007
Posts: 94
#1: Apr 29 '09
Hello,

I have never done any web page tracking in CFM, and now I have been asked to.

I can create a table in my database to hold the information but as a newbie can someone tell me how I start? An overview would be great as I really don't have a clue beyond creating a table to hold whatever data (and I think I know how to create the query to retrieve it).

Cheers!
Neil
best answer - posted by acoder
You can serve HTML pages using Coldfusion too. If you want to pass validation with iframes, either use Transitional, or use JavaScript to generate the iframe onload.
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Apr 29 '09

re: Track Web Page visits in CFM


Depends exactly what you want to track. Unique visitors, page visits, site visits, etc.
Member
 
Join Date: Mar 2007
Posts: 94
#3: Apr 29 '09

re: Track Web Page visits in CFM


Hi acoder,

It's an intranet site, so all I need to store is the username, date and time and page name. Basically its to justify the existence of the website if noone is using it!

Thanks
Neil
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#4: Apr 30 '09

re: Track Web Page visits in CFM


So, you can create a table with 3 fields (plus one for ID): user name, a date/time field and page name field.

In either application.cfm or onrequestend.cfm, add a bit of code which inserts a record in this table: GetAuthUser() for the user name, now() for the date/time and cgi.script_name for page name.
Member
 
Join Date: Mar 2007
Posts: 94
#5: May 6 '09

re: Track Web Page visits in CFM


Thanks acoder. I also needed it to track normal HTML pages so what I did was create a small iframe:

<iframe src="http://marlin/engeastl/scripts/RepairWorkshops/tracker.cfm?name=RWD_HomePage" height="1px" width="1px" frameborder="0">

And used the tracker.cfm page to add the info to the database.

Not Strict HTML compliant, but its works!

Cheers
Neil
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#6: May 6 '09

re: Track Web Page visits in CFM


You can serve HTML pages using Coldfusion too. If you want to pass validation with iframes, either use Transitional, or use JavaScript to generate the iframe onload.
Member
 
Join Date: Mar 2007
Posts: 94
#7: May 6 '09

re: Track Web Page visits in CFM


Quote:

Originally Posted by acoder View Post

You can serve HTML pages using Coldfusion too. If you want to pass validation with iframes, either use Transitional, or use JavaScript to generate the iframe onload.

Good idea!

I'll give that a try as well. Thanks for your help.

Neil
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#8: May 7 '09

re: Track Web Page visits in CFM


No problem :)
Member
 
Join Date: Mar 2007
Posts: 94
#9: May 7 '09

re: Track Web Page visits in CFM


Quote:

Originally Posted by acoder View Post

No problem :)

Also acoder, do you know how I can grab the url of the page I'm tracking, to store it? I have been looking at #CGI.REFERER# but I can't get it to work!

Thanks
Neil
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#10: May 7 '09

re: Track Web Page visits in CFM


Try #cgi.script_name# or do you mean the page that refers to the current one?
Reply