1

I have a simple page view counter on my website, that just counts the number of page views pr post. I am curious to what is a reasonable lifetime for the page view cookie.

I currently have it set to two hours, so more page hits from the same user is not counted for two hours. I have been unsuccessful in finding any articles regarding the subject. After how long is it can it be considered a new page view?

Update: It's only used it to give the visitors an idea of what posts are popular. I am using Google Analytics for more detailed statistics.

2 Answers 2

2

Analytics packages have a similar problem when counting sessions. If a user is on the site in the morning, then comes back that evening, is it one session or two?

Google analytics has a document about how they calculate sessions. They use a half our of inactivity as the threshold for starting a new session. Your two hour window is similar to this.

Since you do use Google Analytics, you might want to set your cookie to half an hour as well. Then the number of sessions that hit that page should be the same as page views that your hit counter reports.

1
  • Thank for for this, this is exactly what I was looking for. Commented Oct 2, 2014 at 6:15
2

It really depends on your site and goals. There isnt a one size fits all approach. What I am wondering is why you are placing a cookie and ignoring future page views. Its pretty valuable information to see if a page is viewed multiple times. For example if you have an e-commerce site and notice that a visitor is viewing a product page 3 times on average before adding an item to cart, you can investigate and try to determine why it takes 3 page views. Maybe in that case you need to build urgency, or display information a bit clearer. My point is, dont throw away good information just because. If you are internally tracking visits, page views, events, collect all the data you can and then filter it out later.

6
  • Good point and thanks for your answer. I am using Google Analytics for that purpose. I have updated the question to include this. Commented Sep 30, 2014 at 15:11
  • Just curious, are you setting a new cookie for each page? For example do I get a home cookie, and about-us cookie and a contact cookie if i view those pages? You want to limit the number of cookies you send, because they are heavy and can cause passing of too much data with your requests. My suggestion is to fallback on a google analtyics type solution storing pageviews in a db, and then setting the time between page views in your metrics. If you are using it for something else like, showing ads, or alerts, then I would assume a cookie lifetime of 24 hours seems right (personal opinion)
    – Frank
    Commented Oct 1, 2014 at 8:55
  • No, the users viewed pages are stored in their session. Along with the time they last accessed it. The only thing I am using it for is trying to give a realistic overview of the popularities of my posts. I do not store individual hits, only a view counter which I increment. That I am really after is (very opinion based of course) what represents a "new page view". Commented Oct 1, 2014 at 9:13
  • If its about a post view, wouldnt a reasonable timeframe be how long it would take to read the post? I would say at most 1 hour?
    – Frank
    Commented Oct 1, 2014 at 9:25
  • That is a very good point indeed, I had not considered using that as a measurement basis. Then I think I will stick with two hours, as my posts are long and detailed descriptions of electronics projects. I'm sorry if my question was unclear as to the purpose of my intent. If you post this as an answer I will accept it. Thank you :) Commented Oct 1, 2014 at 9:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.