[Ruby-on-rails] simple hit counter for page views in rails


Answers

Page views in Rails

I'd recommend this gem: Impressionist

Question

I've found several solutions for this problem, for example railstat from this post:

Page views in Rails

I have a bunch of articles and reviews which I would like a hit counter filtered by unique IPs. Exactly like does for this post. But I don't really care for such a solution as railstat when google analytics is already doing this for me and including a whole lot of code, keeping track of unique IPs, etc.. My present thinking is to use Garb or some other Analytics plugin to pull the pages stats if they are older than say 12 hours updating some table, but I also need a cache_column.

I'm assuming you can pull stats from Analytics for a particular page and that they update their stats every 12 hours?

I'm wondering if there are any reasons why this would be a bad idea, or if someone has a better solution?

Thanks




How to track custom events in paper_trail?

I have found a tweak to add custom events in paper_trail managed Versions. Here is the tweak

Version.create(item_type: "Campaign", item_id: campaign.id, event: "Sent")

May be this is not right solutions but it helped me to achieve the goal. I would explore paper_trail more to find obvious solution.

Please keep posting your suggestions.

Thanks, Amit Patel




Is there a Rails Gem for Page Stats?

Check this similar question simple hit counter for page views in rails. Based on the answer to the mentioned question, a gem named impressionist was created by John McAliley. The gem is Rails 3 ready, so you can include it in your app directly.