Recent Changes - Search:

add Cookbook page

hide

Cookbook


hide

Topics


show

Changed

Visitor's book Site map pmwiki-2.3.32

Total Counter

2023-03-06
pmwiki-2.3.32

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}
  • 4539 PageCount
  • 5,549,277 TotalCount
  • 4539 PageViews
  • 1 PageCountToday
  • 30 TotalCounterMaxItems
  • Version 2023-03-06
(:pagelist group=Aotearoa count=4 order=-{$PageCount} thevar="{$PageCount}" fmt=#tc-pc list=normal:)
PageCounter"4539"
Aotearoa.Days#=4539
Aotearoa.HomePage#=4539
Aotearoa.Kiwiisms#=4539
Aotearoa.Pages#=4539
(:pagelist group=Aotearoa count=4 order=-{$TotalCount} thevar="{$TotalCount}" fmt=#tc-tc list=normal:)
TotalCount"5,549,277"
Aotearoa.Days#=5,549,277
Aotearoa.HomePage#=5,549,277
Aotearoa.Kiwiisms#=5,549,277
Aotearoa.Pages#=5,549,277
(:pagelist group=Aotearoa count=4 order=-{$PageViews} thevar={$PageViews} fmt=#tc-pv list=normal:)
PageViews"4539"
Aotearoa.Days#=5227
Aotearoa.HomePage#=1523375
Aotearoa.Kiwiisms#=12856
Aotearoa.Pages#=7288
(:pagelist group=Aotearoa count=4 order=-{$PageCountToday} thevar='{$PageCountToday}' fmt=#tc-pct list=normal:)
PageCountToday"1"
Aotearoa.Days#=6
Aotearoa.HomePage#=13
Aotearoa.Kiwiisms#=6
Aotearoa.Pages#=1
>>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] nz/Cookbook/TotalCounter) - An update to the [[Cookbook:TotalCounter recipe" | email page as link ]]