Counterizer

Counterizer is a powerful counter and statistics plugin for WordPress. An excellent alternative to “Google Analytics“.

Tags: hits, visit, counter, traffic, statistics, stats, browser, operating, system, graph, chart, diagram

Requires at least: WordPress 5.0.0

Tested up to: WordPress 5.8.1

Stable version: Counterizer v.1.0.1

Donate link: http://daprose.com/donate/

== Description ==

Counterizer is a complete usage counter and statistics plugin for WordPress with no external libraries dependency. A reliable and comprehensive alternative to Google Analytics. It saves visit’s timestamps, visited URL, referring URL, IP addresses, operating systems and browser information used into the current database. It can display total hits, unique hits, and other statistics in your WordPress admin console/dashboard, and in your posts and pages as well.

**Detailed features:**

  • Hourly, daily, weekly, monthly and yearly traffic stats
  • Popular pages and posts stats
  • IP addresses stats
  • Countries stats
  • Referrers stats
  • Outlinks stats
  • Accurate and detailed browsers stats with browser’s name and versions.
  • Accurate and detailed operating system stats with operating system name, versions, and platforms.
  • Keywords stats
  • Powerful history with filters
  • Email reports
  • Dashboard widget for a quick overview of your blog statistics
  • Track real visitors: most bots are excluded from the statistics by default
  • Complete API to use the data of Counterizer charts as you like and create your own Counterizer plugins
  • An administration interface using the WordPress Settings API is available, as well as a dashboard with detailed information and statistics.
  • The users that are authorized to display the Counterizer dashboard can be defined using WordPress capabilities in the settings.
  • Counterizer can display statistics in your pages and posts using shortcuts and widgets.
  • Counterizer can retrieve information about the country of the visitors. The country detection was made possible thanks to the Software77.net database (http://software77.net/cgi-bin/ip-country/geo-ip.pl), and to the author of this script (http://www.phptutorial.info/iptocountry/the_script.html).
  • Counterizer is willing to support the latest version of WordPress as much as possible, but this is always a work-in-progress. Do not hesitate to report any incompatibility issue immediately!

I am not the original author of this plugin. Counterizer root is the old Counterize plugin no loginger supported and now incompatible with newer versions of WordPress; yet, this new version is no longer compatible with previous versions of Counterize anymore; this new “Counterizer” version uses it’s own tables and settings, new and updated logic, and uses a new database structure as well. So, I may not be aware of some of the old bugs if any. You can report them to me, but please, do NOT report Counterize or Counterize II bugs to me as I do not deal with those versions anymore at all. Counterizer now runs on its own.

Counterizer is based on most of the logic of the Counterize 3.1.14 plugin by Steffen Forkmann (http://www.navision-blog.de/counterize) and WordPress Browser Detection Plugin by Iman Nurchyo (http://priyadi.net). Counterizer has evolved a lot since the initial fork, and does not share a lot of common code with the plugins it is based on anymore.

By default, Counterizer will store all IP information unless you manually dissable this feature, the reason you may want to disable it is because it is illegal in some countries (e.g. Germany). For users living in those countries, Counterizer you can store only a small hash to distinguish between different users and to get information about the user count. For other countries, IP addresses will be recorded. This is just an option in the Administration Settings area of Counterizer.

== Installation ==

Download the latest version of Counterizer here:
BY REQUEST ONLY

Automatic Installation

  1. Go to Add Plugin in the Plugin section of the Admin dashboard
  2. Click on Upload Plugin
  3. Upload the Counterizer ZIP file to your Plugin’s
  4. Click on Install (It will automatically upload and install Counterizer)
  5. Activate Counterizer
  6. Go to Installed plugins
  7. Activate the other Counterizer plugins as needed. You can activate all of them to have a complete set of reports for your Website.

Manual Installation

  1. Unzip the package and upload the folder **counterizer** to your **/wp-content/plugins/** folder.
  2. Activate the <<Counterizer>> plugins through the **Plugins** menu in WordPress.
  3. Go to **Counterizer** on the **Settings** menu, and configurate your Counterizer settings. Remember to *Save the settings* after any changes.

== Reporting bugs ==

If you encounter a bug, please send us a descriptive report of what happened, with the screenshot and error messages if any.

== TODO list ==

Legend: [status, priority] Description
* `[wip, medium]` Make a Counterizer widget
* `[10%, low]` Add some sorting options (by label for example)
* `[ 0%, medium]` A new installation should have its own installation script
* `[ 0%, low]` To be able to resize and move charts in the dashboard (but I consider it not urgent)
* `[ 0%, low]` Using the HighCharts library as an alternative fancier display
* `[ 0%, high]` Allow wildcard characters support in IP address exclusion list
* `[ 0%, high]` Solve time zones problems as many reported it
* `[ 0%, high]` Reduce the Counterizer footprint on database [BIG JOB AS ALL QUERIES MUST BE RE-WRITTEN]
* `[ 0%, medium]` Better IP exclusion list handling
* `[ 0%, low]` Add more function to count unique visitors, in a similar way as hits
* `[ 0%, high]` Move some Counterizer functions into their respective plugins
* `[ 0%, medium]` Add screen size statistics

== Counterizer API ==

After you have installed the Counterizer plugin, you can see a lot of diagrams on the Counterizer Dashboard page  (Dashboard/Counterizer).
Most likely you’d like to have a counter somewhere on your pages, showing the number of visitors or similar. Here is an overview of the functions which can be used anywhere in your WordPress blog.
Depending on where you use the Counterizer plugin functions in your theme, you may have to add the following line before using it:
global $counterizer_plugins;

== Traffic functions ==

* `counterizer_getamount() `: Returns the total hits seen by Counterizer.
* `counterizer_getpagesamount() `: Returns the total pages/posts views.
* `counterizer_gethitstoday() `: Returns the total hits registered today.
* `counterizer_get_online_users() `: Returns the number of currently online users.
* `counterizer_getlatest7days() `: Returns the total amount of hits from the last 7 days.
* `counterizer_getuniqueamount() `: Returns the total unique IP’s that’s been seen.
* `counterizer_getfromcurrentip() `: Returns the total hits from the IP that’s visiting.
* `counterizer_getuniquehitstoday() `: Returns the number of different IP’s registered today.
* `counterizer_gethitstodayfromcurrentip() `: Returns the daily hits from the IP that’s visiting.
* `counterizer_current_post_hits() `: Gets number of hits on current post/page.
* `counterizer_return_first_hit() `: Returns the date of the first registered entry in the database.
* `counterizer_get_hits() `: Outputs an HTML table with statistics about hits.
* `$counterizer_plugins[‘traffic’]->counterizer_feed_daily_stats() `: Gets the daily stats data feed.
* `$counterizer_plugins[‘traffic’]->counterizer_render_daily_stats() `: Renders the daily stats data feed.
* `$counterizer_plugins[‘traffic’]->counterizer_feed_monthly_stats() `: Gets the monthly stats data feed.
* `$counterizer_plugins[‘traffic’]->counterizer_render_monthly_stats() `: Renders the monthly stats data feed.
* `$counterizer_plugins[‘traffic’]->counterizer_feed_weekly_stats() `: Gets the weekly stats data feed.
* `$counterizer_plugins[‘traffic’]->counterizer_render_weekly_stats() `: Renders the weekly stats data feed.
* `$counterizer_plugins[‘traffic’]->counterizer_feed_week_progression_stats() `: Gets the progression between the last current week stats data feed.
* `$counterizer_plugins[‘traffic’]->counterizer_render_week_progression_stats()`: Renders the progression between the last current week stats data feed.
* `$counterizer_plugins[‘traffic’]->counterizer_feed_hourly_stats() `: Gets the hourly stats data feed.
* `$counterizer_plugins[‘traffic’]->counterizer_render_hourly_stats() `: Renders the hourly stats data feed.

== Referers functions ==

* `counterizer_getuniquereferers() `: Returns the amount of unique referers that have been recorded.
* `$counterizer_plugins[‘referers’]->counterizer_feed_most_seen_referers() `: Gets the most seen referers data feed.
* `$counterizer_plugins[‘referers’]->counterizer_render_most_seen_referers() `: Renders the most seen referers data feed.
* `$counterizer_plugins[‘referers’]->counterizer_feed_most_seen_referers24hrs() `: Gets the most seen referers data feed for the last 24 hours.
* `$counterizer_plugins[‘referers’]->counterizer_render_most_seen_referers24hrs()`: Renders the most seen referers data feed for the last 24 hours.

== Pages and Posts functions ==

* `counterizer_getuniqueURL() `: Returns the amount of unique URL’s that have been shown.
* `$counterizer_plugins[‘pages’]->counterizer_feed_most_requested_urls() `: Gets the most requested URLs data feed.
* `$counterizer_plugins[‘pages’]->counterizer_render_most_requested_urls() `: Renders the most requested URLs data feed.
* `$counterizer_plugins[‘pages’]->counterizer_feed_most_requested_urls24hrs() `: Gets the most requested URLs data feed for the last 24 hours.
* `$counterizer_plugins[‘pages’]->counterizer_render_most_requested_urls24hrs()`: Renders the most requested URLs data feed for the last 24 hours.
* `$counterizer_plugins[‘pages’]->counterizer_feed_most_popular_posts() `: Gets the most popular posts/pages data feed.
* `$counterizer_plugins[‘pages’]->counterizer_render_most_popular_posts() `: Renders the most popular posts/pages data feed.
* `$counterizer_plugins[‘pages’]->counterizer_feed_most_popular_posts24hrs() `: Gets sthe most popular posts/pages data feed for the last 24 hours.
* `$counterizer_plugins[‘pages’]->counterizer_render_most_popular_posts24hrs() `: Renders the most popular posts/pages data feed for the last 24 hours.

== IP addresses functions ==

* `$counterizer_plugins[‘ip’]->counterizer_feed_most_active_ips() `: Gets the most active IP addresses data feed.
* `$counterizer_plugins[‘ip’]->counterizer_render_most_active_ips() `: Renders the most active IP addresses data feed.
* `$counterizer_plugins[‘ip’]->counterizer_feed_most_active_ips24hrs() `: Gets the most active IP addresses data feed of the last 24 hours.
* `$counterizer_plugins[‘ip’]->counterizer_render_most_active_ips24hrs()`: Renders the most active IP addresses data feed of the last 24 hours.

== Keywords functions ==

* `$counterizer_plugins[‘keywords’]->counterizer_feed_most_searched_keywords() `: Gets the most searched keywords data feed.
* `$counterizer_plugins[‘keywords’]->counterizer_render_most_searched_keywords() `: Renders the most searched keywords data feed.
* `$counterizer_plugins[‘keywords’]->counterizer_feed_most_searched_keywords24hrs() `: Gets the most searched keywords data feed for the last 24 hours.
* `$counterizer_plugins[‘keywords’]->counterizer_render_most_searched_keywords24hrs()`: Renders the most searched keywords data feed for the last 24 hours.

== Countries functions ==

* `$counterizer_plugins[‘countries’]->counterizer_feed_most_visiting_countries() `: Gets the most visiting countries data feed.
* `$counterizer_plugins[‘countries’]->counterizer_render_most_visiting_countries() `: Renders the most visiting countries data feed.
* `$counterizer_plugins[‘countries’]->counterizer_feed_most_visiting_countries24hrs() `: Gets the most visiting countries data feed for the last 24 hours.
* `$counterizer_plugins[‘countries’]->counterizer_render_most_visiting_countries24hrs()`: Renders the most visiting countries data feed for the last 24 hours.

== Browsers functions ==

* `counterizer_getuniquebrowsers() `: Returns the amount of unique browser strings that have visited your blog.
* `$counterizer_plugins[‘browsers’]->counterizer_feed_most_used_browsers_collapsible() `: Gets the most used browsers data feed with detailed version statistics for each item.
* `$counterizer_plugins[‘browsers’]->counterizer_render_most_used_browsers_collapsible() `: Renders the most used browsers data feed with detailed version statistics for each item.
* `$counterizer_plugins[‘browsers’]->counterizer_feed_most_used_browsers_without_version() `: Gets the most used browsers without version data feed.
* `$counterizer_plugins[‘browsers’]->counterizer_render_most_used_browsers_without_version()`: Renders the most used browsers without version data feed.
* `$counterizer_plugins[‘browsers’]->counterizer_feed_most_used_browsers() `: Gets the most used browsers data feed.
* `$counterizer_plugins[‘browsers’]->counterizer_render_most_used_browsers() `: Renders the most used browsers data feed.

== Operating systems functions ==

* `$counterizer_plugins[‘os’]->counterizer_feed_most_used_os_collapsible() `: Gets the most used os data feed with detailed version statistics for each item.
* `$counterizer_plugins[‘os’]->counterizer_render_most_used_os_collapsible() `: Renders the most used os data feed with detailed version statistics for each item.
* `$counterizer_plugins[‘os’]->counterizer_feed_most_used_os_without_version() `: Gets the most used os without version data feed.
* `$counterizer_plugins[‘os’]->counterizer_render_most_used_os_without_version()`: Renders the most used os without version data feed.
* `$counterizer_plugins[‘os’]->counterizer_feed_most_used_os() `: Gets the most used os data feed.
* `$counterizer_plugins[‘os’]->counterizer_render_most_used_os() `: Renders the most used os data feed.

== Actions ==

* `counterizer_show_data `: Let plugins show their data into the “Counterizer” sub-menu page.
* `counterizer_after_includes `: Happens right after Counterizer included its files.
* `counterizer_before_insert_into_database`: Let plugins do something just before some data is inserted into the database.
* `counterizer_after_insert_into_database `: Let plugins do something just after some data is inserted into the database.
* `counterizer_init `: Let plugins add a hook into Counterizer initialization procedure.
* `counterizer_before_install `: Let plugins do something just before installation.
* `counterizer_after_install `: Let plugins do something just after installation.

== Filters ==

* `counterizer_before_includes `: Let plugins filter which files are included.
* `counterizer_server_remote_addr `: Let plugins filter the `$_SERVER[‘REMOTE_ADDR’]` value.
* `counterizer_server_http_user_agent `: Let plugins filter the `$_SERVER[‘HTTP_USER_AGENT’]` value.
* `counterizer_server_request_uri `: Let plugins filter the `$_SERVER[‘REQUEST_URI’]` value.
* `counterizer_server_referer `: Let plugins filter the `$_SERVER[‘HTTP_REFERER’]` value.
* `counterizer_server_this_url `: Let plugins filter the $this_url variable.
* `counterizer_bot_array `: Let plugins filter the bot array.
* `counterizer_check_insert_into_database `: Let plugins add their own conditions for determinating if data should be inserted into the database.
* `counterizer_check_data `: Let plugins add their own diagrams.
* `counterizer_shortcodes `: Let plugins add their own shortcodes.
* `counterizer_dashboard_add_submenu `: Let plugins add their own sub menu.
* `counterizer_mce_js_before_form_filter `: Let plugins output something before the form of the Counterizer modal dialog in the Visual editor.
* `counterizer_mce_js_before_fields_filter`: Let plugins output something before the fields of the Counterizer modal dialog in the Visual editor.
* `counterizer_mce_js_type_filter `: Let plugins add more type items in the Counterizer modal dialog in the Visual editor.
* `counterizer_mce_js_period_filter `: Let plugins add more period items the Counterizer modal dialog in the Visual editor.
* `counterizer_mce_js_after_fields_filter `: Let plugins output something after the fields of the Counterizer modal dialog in the Visual editor.
* `counterizer_mce_js_after_form_filter `: Let plugins output something after the form of the Counterizer modal dialog in the Visual editor.
* `counterizer_mce_js_options_filter `: Let plugins add/modify attributes and their defaults for the Counterizer modal dialog in the Visual editor.
* `counterizer_mce_js_radiobutton_filter `: Let plugins add/modify the list of attributes of type “radio button” for the Counterizer modal dialog in the Visual editor.
* `counterizer_mce_js_checkbox_filter `: Let plugins add/modify the list of attributes of type “checkbox” for the Counterizer modal dialog in the Visual editor.
* `counterizer_report `: Let plugins output some content in the email reports
* `counterizer_report_what_filter `: Let plugins add some items in the list used to generate email reports

== Statistics in your posts and pages ==

= Shortcodes =

You can insert a Counterizer diagram using the Counterizer button in your Visual editor. The most basic shortcode is:
`

Statistics recorded with Counterizer - Version 1.0.1

`

All the attributes are optional. The following attributes and their values are currently available:

  • type: String. Valid values are:
    • “*copyright*”: Shows a copyright notice (default value)
    • “browsers”: Browsers diagrams
    • “os”: Operating systems diagrams
    • “countries”: Countries diagrams
    • “ip”: IP addresses diagrams
    • “hosts”: Hostnames diagrams (only available if enabled in the settings)
    • “outlinks”: Outlinks diagrams
    • “exitpages”: Exit pages diagrams
    • “keywords”: Keywords diagrams
    • “referers”: Referers diagrams
    • “domains”: Domains diagrams
    • “hits”: Hits table
    • “hourly”: Hourly stats diagrams
    • “daily”: Daily stats diagrams
    • “weekly”: Weekly stats diagrams
    • “monthly”: Monthly stats diagrams
    • “all”: All tables and diagrams
  • items: Positive and non-zero integer that represents the number of items to display in the diagram. Default value: 10
  • subitems: Positive and non-zero integer that represents the number of subitems to display in the diagram. Only effective with collapsible diagrams. Default value: 15
  • version: String. Set to “yes” to display diagrams with version information, “no” otherwise. Only effective with Browsers and OS diagrams. Default value: “yes”
  • collapsible: String. Set to “yes” to display collapsible diagrams with each item containing child items, “no” otherwise. Only effective with Browsers and OS diagrams. Default value: “no”
  • print_header: String. Set to “yes” to display a header above the diagram, “no” otherwise. Default value: “yes”
  • header: String. Set to non-empty string to override the default header. Default value: empty string
  • period: String. Valid values are:
    • (empty string): No period limit (default value)
    • “24h”: Limit data to the latest 24 hours. Available for most diagrams except the Traffic ones
    • “onlytoday”: Limit data to today only. Available fpr Traffic diagrams
    • “onlythisweek”: Limit data to this week only. Available fpr Traffic diagrams
    • “onlythismonth”: Limit data to this month only. Available fpr Traffic diagrams
    • “onlythisyear”: Limit data to this year only. Available fpr Traffic diagrams
  • tn_width: Positive and non-zero integer. Width of the post thumbnail. Default value: 50
  • tn_height: Positive and non-zero integer. Height of the post thumbnail. Default value: 50

== botlist.txt ==

Counterizer provides a botlist.txt file. This file is a list of things that should not be counted in the statistics. It is also used to delete bots manually after you edit it. Feel free to modify this list as per your personal needs.
There are three kind of lines you can find in botlist.txt:
* Lines containing part or all of the user-agent to block, without any escaping. If a user-agent contains one of this kind of lines, it will be blocked. Example: “bot”
* Lines containing regular expressions. They must be of the following format, without the quotes: `regexp:my_regular_expression_pattern`.
Example: `regexp:#^Mozilla/5\.0 \(compatible$#` will match exactly the “Mozilla/5.0 (compatible” malformed user-agent.
* Lines containing complex filters. They must be of the following format: `complexfilter:Suspicious_complete_user_agent_string###requested_url###Complete_referer_string`.
“requested_url” can also be “*” if the bot goes to several pages.
If “Complete_referer_string” is “%HTTP_HOST%”, it will be replaced by the complete URL of your website (eg: http://www.yourwebsite.com/).
If “Complete_referer_string” is “unknown”, it means the referer is empty.
Here is an example of complex filter:
`complexfilter:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)###/comment-page-1/###%HTTP_HOST%`
will block any user-agent equal to “Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)”
accessing “/comment-page-1/” with the referer “http://www.yourwebsite.com/”.
Another example: `complexfilter:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)###*###unknown`
will block the “Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)” user-agent
accessing any pages with an empty referer. Complex filters are powerful, use with caution!
You can add your own lines in the file user_botlist.txt. You may create this file if it doesn’t exist.

== Frequently Asked Questions ==

= I know that I have incoming traffic but Counterizer keeps telling me that no data has been recorded yet. Why? =
Right after you install Counterizer for the first time it is obvious the you still do not have any data ready to report. Wait for a few minutes until youo have some visitors. Counterizerr reports get better and better after a few days or weeks. But if after a few hours you still get the same message, there may be a problem somewhere, so I will need you to do the following:
* Open your wp-config.php file
* Ensure that WP_DEBUG variable is set to true. The line should say now:
`define( ‘WP_DEBUG’, false );`
Change it to:
`define( ‘WP_DEBUG’, true );`
* Add the following lines just after:
`error_reporting( E_ALL | E_STRICT );
ini_set(‘display_errors’, 1);`
* Reload your website in your browser
* Then tell me about any errors, warnings and notices you may see, if any.  If no errors are shown, then you probably do not have incoming traffic… Is Counterizer correctly activated?

= How to add a counter for the current post/page in my sidebar? =

You can edit your theme sidebar, or use a PHP/HTML code widget (recommended), and use the following code:
`(counterizer)’ Replace the () with briquets!

It will show: “This page has been viewed ### times.”

= How to make my PHP widget appear only for posts and pages? =

If you use a PHP widget and want the widget to appear only for posts and pages, install the “Widget Logic” plugin and use `is_single() || is_page()` as condition.

= How to add a counter in the footer of my blog? =

Try adding the following line somewhere in your footer.php:
`

Statistics recorded with Counterizer - Version 1.0.1

` the 0 parameter stands for “since forever” and 3600 stands for “count only one visit if the same visitor visit the website less than 3600 seconds after the initial visit”. Both values are optional.

= Why aren’t the IP of my visitors logged? =

You need to enable the option in the Counterizer settings. It is disabled by default.

= Can I extend Counterizer? =

Yes. Counterizer is now modularizable and you can add your own Counterizer plugin. Counterizer also provides several action and filter hooks.

= Can Counterizer replace Google Analytics? =

Not yet. But it’s a good addition/alternative.

= What are the minimum requirements to run Counterizer? =

The same as the current stable version of WordPress, but as with each supplementary plugin, it will use more RAM, so take this into account. Counterizer is also known to take a lot of database space in its current version, especially if your website is very visited.

= I see an error message like “`The script whose uid is 12345 is not allowed to access /var/tmp/” or “Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent`”, HELP! =

Try adding the following 3 lines just after the PHP start tag of your wp-config.php:

`if( ! isset( $_SESSION ) )
{
session_start();
}`

Also, make sure the session.save_path in you php.ini is set and point to a valid path

= Do you provide support for Counterizer? =

**Sometimes**, I can provide BASIC support for free. It mostly depends on my free time because Counterizer is maintained on my free time too. Nobody likes to work for peanuts, so do not expect professional level support for free. If you need a better support or something is urgent, please contact me to discuss my fees.