Recent Changes - Search:

add Cookbook page

hide Cookbook

Cookbook


hide Topics

Topics

show Changed

Changed

Visitor's book Site map pmwiki-2.3.37

Total Counter

2024-12-01
pmwiki-2.3.37

TotalCounter v1.10.0 update

An update to the TotalCounter tool to tidy up the report.

This has been combined with a refactor and tidy up of the PmWiki TotalCounter and TotalCounter-Talk pages.

This was prompted by the following issues

  • a high proportion of counts being classified as "unknown"
  • many if not most visitors are bots[1]
  • use of the deprecated eregi, to make it PHP 5.5 compatible
  • count by year showing many preceding years of zero
  • some layout problems with the report

Upgrade cautions

This update changes some defaults, please review the following:

  • ensure you backup totalcounter.stat
  • $TotalCounterEnableGeoIp now defaults to 0, if you are a GEOIP user set it to 1 in config.php
  • $TotalCounterLogfile now defaults to "$WorkDir/totalcounter.log", previously the $WorkDir was prepended after, this makes it consistent with the other file name parameters
  • Bots OS, Referrer, and Location are no longer counted, to count bots add $TotalCounterCountBots = 1 to config.php
  • some of the recipe's page variables are created differently, check usage of them to ensure expected results

Revision history

1.10.0 - 2014-11-12 - Simon div with class totalcounter to allow styling; friendly names for counts; don't show LastYears of zero; add logfile; log unknowns; add more robots, skip unknown OS if bot; skip unknown referer if bot; skip unknown location if bot; use smaller instead of small; right align percentage; $TotalCounterEnableGeoIp default to 0; enable https referers; use $FmtPV for page variables; Add $TotalCounterEnableUsers; add OSes; use number_format (); add $TotalCounterCountBots

Example from Unknowns log
Example from all visits log

Detailed explanation of changes

This update builds on the changes by 'Nigel' who updated the code from the deprecated eregi to preg_replace. Changes are flagged with a comment in the source code.

  • the entire report is surrounded by <div class=totalcounter> to permit CSS styling
  • names for "Last day", "Last week", changed from "LastDay", etc
  • "Last Years" with a count of zero are not shown
  • text log file for developers added to trace occurrence of "Unknowns", or all visits to the website
  • many more robots added based on reviewing the log files of a couple of accessible sites over several weeks
  • "unknowns" not counted if visitor is a bot for OS, referer, or location
  • in report use smaller instead of small, and in general use CSS
  • in report right align percentage columns
  • set the default for $TotalCounterEnableGEOIP to 0
  • enabled HTTPS referrers
  • moved $count out of a loop and used strpos instead of strstr for efficiency
  • TotalCounterEnableDownload was declared but not used, implemented it
  • use $FmtPV for page variables (users of page variables should check they get the expected results)
  • add $TotalCounterEnableUsers (default 0) to display users (requires AuthUser or UserAuth)
  • use number_format to add thousand delimiters to counts
  • add OSes: iPhone; Android
  • $TotalCounterEnableCountBots default 0, changes TotalCounter so that unless set TotalCounter only counts Bots in the Bot chart, and does not count them for OS, Location, or Referer.

Review or test

Code reviewers or Beta testers are welcome.

Before installing please take a backup of your totalcounter.stat file.

Testing notes

Testing took place over several weeks.

  • monitored the php.log file for errors
  • monitored the totalcounter.log file for unknowns, new bots, and new browsers
  • checked report and counts visually
  • tested page variables below
* {$PageCount} PageCount
* {$TotalCount} TotalCount
* {$PageViews} PageViews
* {$PageCountToday} PageCountToday
* {$TotalCounterMaxItems} TotalCounterMaxItems
* Version {$TotalCounterVersion}
  • 4,752 PageCount
  • 5,780,463 TotalCount
  • 4,752 PageViews
  • 2 PageCountToday
  • 30 TotalCounterMaxItems
  • Version 2024-12-01
(:pagelist group=Aotearoa count=4 order=-{$PageCount} thevar="{$PageCount}" fmt=#tc-pc list=normal:)
PageCounter"4,752"
Aotearoa.Days#=4,752
Aotearoa.HomePage#=4,752
Aotearoa.Kiwiisms#=4,752
Aotearoa.Pages#=4,752
(:pagelist group=Aotearoa count=4 order=-{$TotalCount} thevar="{$TotalCount}" fmt=#tc-tc list=normal:)
TotalCount"5,780,463"
Aotearoa.Days#=5,780,463
Aotearoa.HomePage#=5,780,463
Aotearoa.Kiwiisms#=5,780,463
Aotearoa.Pages#=5,780,463
(:pagelist group=Aotearoa count=4 order=-{$PageViews} thevar={$PageViews} fmt=#tc-pv list=normal:)
PageViews"4,752"
Aotearoa.Days#=5,520
Aotearoa.HomePage#=1,542,811
Aotearoa.Kiwiisms#=13,283
Aotearoa.Pages#=7,681
(:pagelist group=Aotearoa count=4 order=-{$PageCountToday} thevar='{$PageCountToday}' fmt=#tc-pct list=normal:)
PageCountToday"2"
Aotearoa.Days#=3
Aotearoa.HomePage#=239
Aotearoa.Kiwiisms#=3
Aotearoa.Pages#=6
>>comment<<
[[#tc-pc]]
(:template first:)
||!PageCounter ||!"{$$thevar}" ||
(:template each:)
||[-{=$Group}.-]{=$Name} ||#={=$PageCount} ||
[[#tc-pcend]]

[[#tc-tc]]
(:template first:)
||!TotalCount ||!"{$$thevar}" ||
(:template each:)
||[-{=$Group}.-]{=$Name} ||#={=$TotalCount} ||
[[#tc-tcend]]

[[#tc-pv]]
(:template first:)
||!PageViews ||!"{$$thevar}" ||
(:template each:)
||[-{=$Group}.-]{=$Name} ||#={=$PageViews} ||
[[#tc-pvend]]

[[#tc-pct]]
(:template first:)
||!PageCountToday ||!"{$$thevar}" ||
(:template each:)
||[-{=$Group}.-]{=$Name} ||#={=$PageCountToday} ||
[[#tc-pctend]]
>><<

(:template first:)

PageCounter"{$$thevar}"

(:template each:)

{=$Group}.{=$Name}#={=$PageCount}

(:template first:)

TotalCount"{$$thevar}"

(:template each:)

{=$Group}.{=$Name}#={=$TotalCount}

(:template first:)

PageViews"{$$thevar}"

(:template each:)

{=$Group}.{=$Name}#={=$PageViews}

(:template first:)

PageCountToday"{$$thevar}"

(:template each:)

{=$Group}.{=$Name}#={=$PageCountToday}

tahi Page last modified on 2022 Apr 25 18:28

Edit - History - Recent Changes - WikiHelp - Search - TotalCounter -> mailto:?Subject="KiwiWiki: Total Counter"&Body="From KiwiWiki: Total Counter (http://kiwiwiki [period] co [period] nz/Cookbook/TotalCounter) - An update to the [[Cookbook:TotalCounter recipe" | email page as link ]]