add Cookbook page
|
Total Counter
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
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,820 PageCount
- 5,854,070 TotalCount
- 4,820 PageViews
- 4 PageCountToday
- 30 TotalCounterMaxItems
- Version 2024-12-12
|
(:pagelist group=Aotearoa count=4 order=-{$PageCount} thevar="{$PageCount}" fmt=#tc-pc list=normal:)
| PageCounter | "4,820" |
Aotearoa.Days | #=4,820 |
Aotearoa.HomePage | #=4,820 |
Aotearoa.Kiwiisms | #=4,820 |
Aotearoa.Pages | #=4,820 |
|
(:pagelist group=Aotearoa count=4 order=-{$TotalCount} thevar="{$TotalCount}" fmt=#tc-tc list=normal:)
| TotalCount | "5,854,070" |
Aotearoa.Days | #=5,854,070 |
Aotearoa.HomePage | #=5,854,070 |
Aotearoa.Kiwiisms | #=5,854,070 |
Aotearoa.Pages | #=5,854,070 |
|
(:pagelist group=Aotearoa count=4 order=-{$PageViews} thevar={$PageViews} fmt=#tc-pv list=normal:)
| PageViews | "4,820" |
Aotearoa.Days | #=5,588 |
Aotearoa.HomePage | #=1,548,118 |
Aotearoa.Kiwiisms | #=13,443 |
Aotearoa.Pages | #=7,813 |
|
(:pagelist group=Aotearoa count=4 order=-{$PageCountToday} thevar='{$PageCountToday}' fmt=#tc-pct list=normal:)
| PageCountToday | "4" |
Aotearoa.Days | #=4 |
Aotearoa.HomePage | #=114 |
Aotearoa.Kiwiisms | #=3 |
Aotearoa.Pages | #=5 |
|
>>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:)
(:template each:)
{=$Group}.{=$Name} | #={=$PageCount} |
(:template first:)
(:template each:)
{=$Group}.{=$Name} | #={=$TotalCount} |
(:template first:)
(:template each:)
{=$Group}.{=$Name} | #={=$PageViews} |
(:template first:)
PageCountToday | "{$$thevar}" |
(:template each:)
{=$Group}.{=$Name} | #={=$PageCountToday} |
|
|