Matomo counter plugin - Display Hits/Visits on image



Screenshot of the plugin backend

Matomo (Piwik) plugin that display an image counter (default image 80x31) with the site visits and page views.

We have a plug-in administrator part with the settings and actually the part that is responsible for the output image counter. Installing counter javascript-code on the site is required!

Download (version 2.1.3) for Matomo (Piwik) 3.x: plg_counter_2.1.3.zip
MD5: 119b0f685b26178cd99838436041dece
SHA1: 5d47a9d51dfdedabd65e3d7a9ae78c365f312223

Download (version 2.0.15) for Piwik 2.x: plg_counter_2.0.15.zip
MD5: 25dab3c45f253b45f129708c7ef27e44
SHA1: a3f717b023f693762f7cb93d05ba041dca651d79

Download (version 1.1) for Piwik 1.x: plg_counter_1.1.zip
MD5: ff51c4d586405773dfc049643db558f8
SHA1: 5d7daeb5861e9c5cbd689101cd4a0e4522935f7c

Distributed under the GNU GPLv3 license

Repository on Github

Older versions can be found here.

Now, about how to install, configure plugin and how it all works.

  1. Requirements
  2. Installation
  3. Managing counters
  4. Adding on the site
  5. Users online
  6. Screenshots
  7. Translations

Requirements

PHP 5.3 or later
GD2+
FreeType

Installation

For version 2.0: Download plugin and unpack its content into the folder "plugins/Counter"
For version 1.1: Download plugin and unpack its content into the plugins folder "plugins/"
Then go to a "Settings - Plugins" and search for a "Counter" in the plugins list. Click the link "Activate".
NB Please check the files and folders permissions.

Managing counters

Go to a "Counter" tab in the settings of Piwik

By default, after installing the counter list is empty. The user can create a new counter for the site, for which it has administrative rights. You also can not create multiple counters for the same site.
If the counter is removed from the publication, instead of the image with statistics will appear transparent gif image in a 1x1 px.

When you add a counter in the list of sites will be available to only those for which the user has administrator rights.

The administrator can view, edit, delete, publish all user-generated counters, regardless of user access rights to a particular site.

Adding on the site

To display the counter on the page, you must write in the place where the counter is needed:

<img src="http://my_piwik_site/index.php?module=Counter&action=show&id=1" border="0" />
where id - counter number from a list

Users online

"Counter online" allows you to display the number of visitors in real time, over a specified interval. To do this, when you create a counter, you must specify the period for which the user account on the website, the update interval, the counter type and id of the element on the page which will display statistics. "Static meter" displays the statistics only when the page is requested by the user. If this option is disabled, then the statistics will be updated after a specified period of time. Counter code are available on the list of counters.

Screenshots


Translations

Finished and corrected translations for other languages you can add at https://github.com/Globulopolis/Counter/pulls

 


Q: - How it works?
A: - The plugin makes a request to an internal API Piwik, namely the method "VisitsSummary"with the parameters.

$request = new Request(' method=VisitsSummary.get &idSite='.(int)Common::getRequestVar('idSite', 0).' &period=range &date='.$params['start_date'].','.date('Y-m-d').' &format=php &serialize=0 &token_auth='.$params['token'] );

 

Q: - Why count the total statistics takes a very long time?
A: - The calculation takes a long time, for the reason that the system counts all visits for a selected period of time. Also, if our database has no archives for a period of time, the system creates a new tables with data and then calculates the visit. For high-loaded sites recommended to install the backup time and cache as much as possible.

Changelog

2.1.3
* Implements basic caching mechanism(Zend Cache removed from Matomo 3.11).
* Minor fixes.

2.1.1
* Add form token for some actions: publish/unpublish, save/apply, remove, clearCache.
* Remove publish/unpublish, save/apply, remove from API.
* Remove X-Powered-By header from image responce.
* Minor fixes.

2.1.0
* New plugin version for Piwik 3.

2.0.15
* Increase version number(wrong tagging).

2.0.14
* Fix code style.
* Code clean up.

2.0.13
* Remove initial value checks for visits.
* Fix extra space in counter code.
* Fix missing columns in UPDATE query on save()
* New option to format numbers into human readable format.

2.0.12
* Fixed error with access rights.

2.0.11
* User can now add initial values to numbers of visits/views.
* New template support Piwik 2.14. Non B/C.

2.0.10
* See https://github.com/Globulopolis/Counter/issues/7
* Add "require" into plugin.json because new menu required at least Piwik 2.4.0
* Fixed icon in "Check for updates" modal.

2.0.9
* See https://github.com/Globulopolis/Counter/issues/5

2.0.8
* See https://github.com/Globulopolis/Counter/issues/4#issuecomment-59620132

2.0.7
* Add 'yesterday' option for "Start date - period".

2.0.6
* Fixed an error when user select image with type different from png or gif. Now plugin support jpg image type.
* Update colorpicker to latest.

2.0.5
* Fixed a bug w/ undefined variable 'userMenu' in '@CoreHome/_topBarTopMenu.twig' on new Piwik 2.4.0

2.0.4
* Added custom offsets for visits/views/countries for 'visitors by countries' template.

2.0.3
* Added custom template for 'visitors by countries'. NB! 'Live visitors counter' works only if custom template field for 'Visitors by countries' is empty.
* Fixed an error w/ undefined method Access::isSuperUser
* Fix for double slash in ajax url
* Added workaround for getallheaders() method if PHP running as CGI.
* Remove PIWIK_ENABLE_DISPATCH due to triggering an error while generating counter image.

2.0.2
* Fixed a bug where the URL with the image displayed via http, if you are using https(bug only in counters list).

2.0.1
* Fix for CORS (thanks for aureq for patch)
* Changing versioning according to requirements

2.0
* Initial release for Piwik 2.x

1.1
* Fixed a bug in SQL-query for installation

1.0
! Due to the limitation of the GD2 library, you cannot use in the sitename characters other than Latin. Turn off the site name and write it in Photoshop or in any other image editor.
* The "site name" moved from json-array in a separate field in the table to workaround problems with the encoding.
* Added check for installed Fileinfo. If not, use Mime_magic. If not, then error is output.
* Fixed receiving of the data about the sites to the list when creating/editing counter
* Updated the "update" method to upgrade from 0.9 to 1.0

0.9
+ Added a selection list of the period of calculation
+ Added checking the new version of the footer
* When selecting a site from the list, in the date field, if it is empty, automatically substituted date add the site to the system
* When choosing a period of "Day" the cache lifetime is set to 1 day
* Fixed display of template pages for counter list, adding and editing
* Updated the method of "update" to update from 0.7 to 0.9

0.8
* Piwik_Query changed to Zend_Db
- Removed "font_size" and added 'sitename_font_size', 'visits_font_size', 'hits_font_size' for each label
* createImage return false if Piwik_API_Request return an error and if FINFO module not loaded
+ Now user can preview edited counter image w/o saving.
+ New "update" method for updating from 0.7 to 0.8
+ Now user can clear the cache of cached counter images
* Some visual changes on Add/Edit pages
* Language updates

0.7
* При удалении счетчика стандартное окно заменено диалоговым jQueryUI. Не требуется перезагрузка страницы
- Удален выпадающий список с опциями расположения надписи сайта. Вместо этого настройки для каждой надписи вынесены отдельно.
+ Добавлены опции по скрытию надписей.
NB! Need to resave previously created counters!

0.6
* исправлена навигация при переходе с страницы редактирования/добавления
+ добавлено предупреждение при отключении кеширования

0.5
+ добавлен пропущенный код для вывода статистики при отключенном кешировании
* мелкие исправления

0.4
Плагин полностью написан заново.
+ разделение прав (зависит от глобальных настроек прав)
+ добавление счетчика для каждого сайта по отдельности
+ добавлена статистика посещений online

0.3
* Экземпляр класса контроллера счетчика назначен переменной и вынесен в конструктор.

0.2
* idSite вынесен из общих настроек в параметры запроса
* date вынесен в параметры запроса. Оставлен в глобальных для тех сайтов, для которых требуется только один счетчик.
+ Добавлена локализация для английского языка.
+ Добавлена автоматическая подстановка пути к файлам image.png и файла шрифта в настройках.
+ Добавлен блок с примером кода для счетчика в настройках.

0.1
Initial release