Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3431046
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:16:41+00:00 2026-05-18T07:16:41+00:00

I am developing a website, where I need to track number of views for

  • 0

I am developing a website, where I need to track number of views for a particular content (lets say articles).

Its very similar to stackoverflow’s views for a question.

I don’t know how stackoverflow does it. Basically it should

  1. Increment the view when a user other than the article author visits the article. If he keeps hitting refresh button, it should not increment the view.
  2. Not increment the view if a visitor hits the refresh button continuously.But it should increment for the first visit.

I have a field in the database to hold number of views.

Anybody know how stackoverflow does it? Is there any plugin in rails which I can use? I guess I should use sessions and IP address to keep track… Should I make use of Logs? OR Google Analytics?

help…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T07:16:41+00:00Added an answer on May 18, 2026 at 7:16 am

    Depending on how accurate you need it to be, you’ll probably need to have a table containing records for which user has read which article. Their MAC address isn’t sent with their HTTP request, and their IP(v4) address is probably not unique enough.

    If you want to display the data (like stackoverflow does), you can’t really use analytics.

    It will be easier to add code to your controller methods to increment a database field than parsing logfiles and hooking into the database outside of Rails.

    Pseudo-ish code (check API for syntax):

    ArticlesController < ApplicationController
      def show
        @article = Article.find(params[:id])
        # Create an ArticleReading (your join table) for this user unless one already exists
        current_user.article_readings.find_or_create_by_article_id(@article)
        # Count the number of users that have read this article
        @article_readings = ArticleReading.count(@article.id)
      end
    end
    

    You can use a plugin for this – I’ve used one before for marking things as ‘read’, which would probably be suitable (or at least adaptable). Have a read of this question, and hit up google.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing website where I need to execute one code at particular time. Which
say I'm developing a website.com. I need to get the root (website.com) dynamically (for
I'm developing a CMS for my website. I need track Users activities in my
I am developing a website in asp.net using dotnetnuke cms. I need to add
I'm developing a website using the Django framework, and I need to retrieve Jabber
I am currently developing a website and i need that the pages loads dynamically
I'm developing an website using asp.net mvc with MySQL and I need to make
We are developing a website quite similar with ebay.com and in order to upgrade/maintain
I'm using MVC2 and VS2010 developing a website and need to use Application State
I am developing a website and I need to receive payments from PayPal and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.