views:

65

answers:

2

I have a collection of links which are being displayed on the index page. Whenever a user clicks a link I want to keep a track of the number of unique views. I know it can be done by tracking the ips whenever a click happens by request.remote_ip and then the link of the page that was clicked. Is there any better approach ? Any plugins etc.

+2  A: 

google analytics :)

Daniel
Upvoted, because it's true.You could probably keep track of the unique views with some sort of Rack plugin, or even just a before_filter in the ApplicationController. But Google Analytics, or something similar, is definitely the easiest way.
Stephen Orr
+1  A: 

Usual approach would be to assign random UserID, store it in a cookie and write it in a log entry each time a user performs an action, either to a DB table or a log file. Later you easily get your unique counts either by SQL query, or by grep | sort | uniq | wc-ing your logs.

I guess you may find a plugin for it, but not much manual work either.

Mladen Jablanović
Thanks. Looks like Google Analytics or the method I had in mind are the only two ways.
alokswain