Running 5.2 and have just noticed that the statistics' module is not counting all page views, in particular those of anonymous users.

If I log out to become an anonymous user (and clear my cache), then reload a page 10 times (allowing for the whole page to load each time), the node counter does not change. If I login again I'll find the counter has increased by perhaps two or three.

I don't understand this and am worried as it suggests lots of page views by anonymous visitors are passing uncounted.

Any suggestions?

For the record:

* access log is enabled

* node view counter is enabled

* discard access logs older than set to 4 weeks

Under Administer > User management > Access control, the statistics module is set to allow all roles, including anonymous users, to view post access counter.

Have searched handbook and forums without success.

Thanks for any ideas on this one.

Comments

gpk’s picture

You should find that the first page view by a particular anonymous visitor *is* counted, but subsequent (repeat) page views by the same visitor aren't. This is because when the browser requests the page on the 2nd and subsequent attempts to view it sends an "If modified since " header (if the page is stored in the browser's cache, which it usually will be). Drupal checks the time/date and if the copy in the browser's cache is up-to-date it returns a 304 Not modified header to the browser which tells the browser to use the local cached copy (http://api.drupal.org/api/function/drupal_page_cache_header/5). However at this point all processing is terminated by calling PHP's "exit()" and the usual code to record the page view http://api.drupal.org/api/function/statistics_exit/5 is therefore bypassed.

The behaviour seems to be the same in D6 and D7 and looks to date back at least to 4.6 http://api.drupal.org/api/function/drupal_page_header/4.6. It's been on my list (for several months) to open an issue about this.

The only way I can see to work round this would be to hack includes/bootstrap.inc, which is not ideal since you would need to re-implement the change every time you upgrade Drupal core.

gpk
----
www.alexoria.co.uk

HowardLake’s picture

Thanks gpk. That explains it well. At least it has confirmed my suspicion that page views are being under-reported to some degree.

Howard Lake
www.fundraising.co.uk

gpk’s picture

Yes, it's just repeat pageviews for anonymous users that aren't counted, though they are counted if you are logged in. However I'd imagine that "most popular content" rankings will be unaffected.

It looks like you are running Google Analytics which IIRC reports both total and "unique" pageviews. Presumably Drupal is reporting something in between..!

gpk
----
www.alexoria.co.uk

dave reid’s picture