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 3.0.3) for Matomo 4.x:
MD5: 0fd7e71042f6d8c42c6cad2d3d5a5491
SHA256: 0d1f5f290c8a75ee60b501b54a48d4a96d266739c30f2cef7f5667412ea2c2b2

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

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

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

Distributed under the GNU GPLv3 license

Repository on Github

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


PHP 5.3 or later


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 Matomo

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_matomo_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.



Finished and corrected translations for other languages you can add at


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

$request = new Request('method=VisitsSummary.get&idSite=' . (int) $params['idsite'] . '&period=range&date=' . $date . ',' . date('Y-m-d') . '&format=json&&filter_limit=-1&token_auth=' . $params['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.


* Fixed security issues.

* The link for the js-script respects the force_ssl parameter.

* New plugin version for Matomo 4.

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

* 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.

* New plugin version for Piwik 3.

* Increase version number(wrong tagging).

* Fix code style.
* Code clean up.

* 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.

* Fixed error with access rights.

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

* See
* Add "require" into plugin.json because new menu required at least Piwik 2.4.0
* Fixed icon in "Check for updates" modal.

* See

* See

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

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

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

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

* 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.

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

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

* Initial release for Piwik 2.x

* Fixed a bug in SQL-query for installation

! 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

+ 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

* 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

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

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

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

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

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

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

Initial release