Recent Changes - Search:

add Cookbook page

hide

Cookbook


hide

Topics


show

Changed

Visitor's book Site map pmwiki-2.2.109

Total Counter

2017-10-20 - v1.11.1
pmwiki-2.2.109

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
  • 661 PageCount
  • 478545 TotalCount
  • 661 PageViews
  • 2 PageCountToday
  • 30 TotalCounterMaxItems
  • Version 2017-10-20 - v1.11.1
PageCounter"661"
TableDB.ReadTable5#=661
TableDB.ReadTable4#=661
TableDB.ReadTable6#=661
TableDB.ReadTable7#=661
TotalCount"478545"
TableDB.ReadTable5#=478545
TableDB.ReadTable4#=478545
TableDB.ReadTable6#=478545
TableDB.ReadTable7#=478545
PageViews"661"
TableDB.ReadTable5#=364
TableDB.ReadTable4#=580
TableDB.ReadTable6#=334
TableDB.ReadTable7#=343
PageCountToday"2"
TableDB.ReadTable5#=1
TableDB.ReadTable4#=1
TableDB.ReadTable6#=1
TableDB.ReadTable7#=1

(: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}

Page last modified on 2014 Nov 15 02:51

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