Koko Analytics


Koko Analytics is a privacy-friendly, simple and lightweight analytics plugin for WordPress. It does not use any external services, so data about your visitors is never shared with any third-party.
No visitor specific data is collected, only aggregated counts.

Stop sharing visitor data with third-party companies who also happen to sell ads.

Stop unnecessarily slowing down your website.

Koko Analytics lets you focus on the important metrics, while respecting the privacy of your visitors.


  • Plug and play: After installing and activating the plugin, stats will automatically be collected.
  • No external services: Any data never leaves your server.
  • No personal data or anything visitor specific is tracked.
  • No cookies: There is an option to not use any cookies.
  • Fast: Handles hundreds of concurrent pageviews without breaking a sweat.
  • Lightweight: Adds less than 950 bytes of data to your pages. A year worth of data will take up less than 10 MB of storage.
  • GDPR: Compliant by design.
  • Metrics: All the essentials: total pageviews, unique pageviews and referral URL’s.
  • Referrer spam: Built-in blocklist to filter out referrer spam.
  • Cached: Fully compatible with pages served from any kind of cache.
  • Open-Source: The plugin code is open-sourced under the GPL-3.0-or-later license.
  • Tested: Ready for PHP 8.3, but compatible down to PHP 7.3.
  • AMP: Tracks AMP powered pages too (official AMP plugin only).


You can contribute to Koko Analytics in many different ways. For example:


  • Koko Analytics' dashboard to view your website statistics.
  • The settings page where you can exclude certain user roles from being counted.
  • A widget to show your most viewed posts (or any other post type) for a given period.
  • The dashboard widget to quickly show your site visits over the last 2 weeks.


You can install Koko Analytics in multiple ways:

After installing and then activating the plugin, statistics will be collected right away.

You can view your analytics dashboard by going to WP Admin > Dashboard > Analytics.


Does this respect my visitor’s privacy?

Yes, absolutely. Koko Analytics only stores aggregated counts. Nothing visitor specific is tracked.

Does this use any external services?

No external servives are used. All data lives on your server alone.

Does Koko Analytics set any cookies?

By default yes, but you can disable it.

Koko Analytics sets a single cookie named _koko_analytics_pages_viewed with a lifetime of 6 hours. This cookie is used to reliably detect unique pageviews and returning visitors without having to store any personal information on your server.

You can disable the use of cookies from the plugin’s settings page.


Will this slow down my website?

No, the plugin is built in such a way that it never slows down your website for your visitors.

  • It only adds a single script of less than 800 bytes to your pages.
  • All heavy lifting (like aggregating the statistics) is done in a background process.
  • Everything lives on your server, so the plugin doesn’t add any additional DNS look-ups and can benefit from your server’s cache policy.


Is the code for this plugin on GitHub?

Yes, see github.com/ibericode/koko-analytics.

Where can I find more documentation?

Have a look at the Koko Analytics knowledge base.

How to show number of visits to a page?

You can use the [koko_analytics_counter] shortcode to show the number of visitors to the current page.

It takes 3 optional arguments:

  • days: Show count over the last N days. Defaults to “3650”.
  • global: Whether to show the global count (for the entire site) or for the current page only. Defaults to “false”.
  • metric: One of “visitors” or “pageviews”. Defaults to “visitors”.

Example use with arguments:

[koko_analytics_counter days="30" metric="pageviews" global="true"]


15 de febrero de 2024
Very happy with the simplicity and accuracy of this plugin for analytics. Would love to be able to access and use the Pro version for the custom event tracking. Looks like I missed the window on the pro version but I hope the developer can come back to it in the future or make an exception so I can access.
3 de febrero de 2024
Koko Analytics is simple to install,customize and understand. It also has a Most Viewed Posts feature to go along with it's analytics program.
22 de diciembre de 2023
I don't like the idea of very complex and granular analytics. I typically don't need or have time to review analytical tools like that. I just want to see the number of visitors, popular pages, and maybe a couple of other things. This plugin covers it. Most importantly, it looks clean. At least currently, there are no ads or other gaudy things in the dashboard.
7 de diciembre de 2023
I just needed a simple, self-hosted plugin to have a rough idea of website traffic. This just does that: There is a handy no-cookie option (as it should be) Works with static-/supercaching, even through Cloudflare Does not get in your way with ads or nagging to upgrade Can't really think of any negatives, really. It's not as feature rich as Google Analytics, of course, but that's kind of the point. You just slap it on your site and it immediately starts collecting the most important basic stats. And does so in a privacy friendly way, because it all runs on your server.
9 de noviembre de 2023
<font _mstmutation="1"></font><font _mstmutation="1" _msttexthash="262941965" _msthash="443">Bin sehr zufrieden, vielen Dank! Ich habe jahrelang GAinWP genutzt, aber das wird nicht mehr unterstützt bzw. seit 3 Jahren nicht mehr aktualisiert. Andere Alternativen liefern falsche Daten bzw. lassen Daten aus. Diese sind so schlecht, das ich alle 3, 4 Plugins entfernen musste, da sie ohne korrekte Daten wertlos sind. Da ich aber unbedingt eine Kontrolle der Besucher benötige, habe ich Koko getestet und nichts erwartet. Da ich seit Jahren die ungefähre Zahl und das Verhalten der Nutzer im Durchschnitt kenne, kam dieses Plugin am besten an diese Zahl ran. Es liefert sogar mehr Infos/ mehr Details als GAinWP und man kann besuchte Seiten auch direkt anklicken, statt das diese nur gelistet sind. Kann ich gerne weiter empfehlen. </font>
Leer todas las 111 reseñas

Colaboradores y desarrolladores

«Koko Analytics» es un software de código abierto. Las siguientes personas han colaborado con este plugin.


«Koko Analytics» ha sido traducido a 20 idiomas locales. Gracias a los traductores por sus contribuciones.

Traduce «Koko Analytics» a tu idioma.

¿Interesado en el desarrollo?

Revisa el código , echa un vistazo al repositorio SVN o suscríbete al registro de desarrollo por RSS.

Registro de cambios

1.3.7 – Feb 26, 2024

  • Add [koko_analytics_counter] shortcode. Thanks Anil Kulkarni!
  • Show time since last aggregation on settings page.
  • Validate data collection request more aggressively before writing to buffer file.
  • Update referrer blocklist.

1.3.6 – Jan 29, 2024

  • Update referrer blocklist.
  • Update third-party JS dependencies.

1.3.5 – Jan 8, 2024

  • Fix HOUR_IN_SECONDS constant not defined when using AMP with cookie enabled.
  • Fix days without any data not showing up in chart.
  • Improve chart y-axes for numbers just above 100.000.

1.3.4 – Nov 21, 2023

  • New feature that allows you to filter by page. Clicking any page in the “top pages” list now updates the totals and chart component to only show visitors and pageviews for that specific page.
  • Fix warning that cron event isn’t working not showing.
  • Fix error when default date period is stuck at removed period.
  • Fix API url for sites not using pretty permalinks.
  • Performance improvement for rendering chart and tooltips.

1.3.3 – Nov 6, 2023

  • Fix quick navigation going forward.
  • Add manifest.json file so (standalone) dashboard can be installed as a Progressive Web App.

1.3.2 – Nov 2, 2023

  • Fix chart tooltip immediately disappearing when viewing the dashboard widget on touch devices.
  • Fix fatal error if lacking permissions to read database size from MySQL information tables.
  • Fix double encoding of special characters in post titles.
  • Fix arrow-key or arrow-icon navigation when viewing a single day of data.
  • Automatically refresh dashboard data every 60s.
  • Improve dashboard widget by showing a summary of today.
  • Added filter hook koko_analytics_dashboard_widget_number_of_top_items to modify or disable the top pages and referrers in the dashboard widget.
  • The [koko_analytics_most_viewed_posts] shortcode now shows a debug message if the arguments did not lead to any results.

1.3.1 – Nov 1, 2023

  • Fix new visitors not being counted.
  • Fix dashboard issues for users with a large UTC timezone offset.
  • Fix date format in chart component if grouping by month.
  • Revert to blue colors for the chart. If you want your chart to use different colors, please see this example code snippet on how to change colors.
  • Change dashboard widget to show just a quick summary of today.
  • Show some feedback after using the “create optimized endpoint” button.

1.3.0 – Oct 31, 2023

  • Major performance improvements for the dashboard by removing the dependency on React and further optimizations.
  • Added link for loading the dashboard outside of WordPress admin (standalone).
  • Added setting to make the analytics dashboard publicly available.
  • Only show button to create optimized endpoint file if location is writable.
  • Remove wp_koko_analytics_dates on plugin uninstall.
  • Optimized database query for getting most viewed posts and cache its results.
  • Expand dashboard widget to include realtime pageviews and a list of the most viewed posts.
  • Use navigator.sendBeacon for data collection requests.

1.2.2 – Oct 18, 2023

  • Fix link to settings page from plugins overview page.
  • Fix pagination not working because wp_localize_script turns everything into a string.
  • Fix React warning for dashboard widget when toggling visibility more than once.
  • Fix chart tooltip not showing on touch devices.
  • Minor styling improvements to settings page.
  • Install custom endpoint on plugin activation only.
  • Add button to settings page to re-attempt custom endpoint installation.
  • Move table pagination to bottom of component and add text label.
  • Wrap input[type="radio"] in <fieldset> tag.
  • Remove support for honouring “Do Not Track” header as per MDN recommendations.

1.2.1 – Oct 11, 2023

  • Fix issue with strict types and non-hourly UTC offsets.

1.2.0 – Oct 11, 2023

  • Fix compatibility with WordPress 6.0.
  • Fix aggregation process not running for 5 minutes if an earlier run failed somehow.
  • Fix chart tooltips not showing on WordPress dashboard.
  • Minor performance improvements for aggregation process.
  • Move seed (sample data) function out of the core plugin.
  • Add message about checking browser console for error message in case the dashboard doesn’t boot up.
  • Format dates in dashboard using Intl.DateTimeFormat in browser, if available.
  • Remove Pikaday datepicker in favor of native <input type="date"> elements.
  • Improve mobile view of datepicker dropdown.
  • Exclude (fixed page) homepage from most viewed posts widget/shortcode/function.
  • Add filter hook koko_analytics_items_per_page to override the number of items to show per page for the dashboard components.
  • Bump required PHP version to 7.3.

1.1.2 – Oct 3, 2023

  • Fix broken totals and chart component on sites using a custom database table prefix.

1.1.1 – Oct 3, 2023

  • Fix for date table not being created, leading to an empty chart as of v1.1.0.

Koko Analytics v1.1.0 – Oct 3, 2023

  • Switch out Preact for the React version that is bundled with WordPress, reducing bundle size for the admin dashboard by 40 kB (or 30%).
  • Stop showing warning about WP Cron events not running if on local or developer environments.
  • Use the same Browserslist configuration as WordPress core.
  • Performance optimizations for fetching and parsing chart data.
  • Create optimized endpoint for fetching data for the totals component.
  • Settings page is now a server-side rendered page instead of a React component.
  • Improved CSS selector performance.
  • Add public PHP API. You can now call the following functions:
    • koko_analytics_get_most_viewed_posts() to get a list of the most viewed posts.
    • koko_analytics_get_realtime_pageview_count('-1 hour') to get the total number of pageviews in the last hour.
    • koko_analytics_track_pageview($post_id) to track a pageview to the post with ID $post_id

1.0.40 – Sep 14, 2023

  • Fallback to post slug if post has no title
  • Validate referrer URL and ignore if invalid
  • Delete optimized tracking endpoint if buffer filename changed and is no longer present in it. This fixes an issue when moving between servers
  • Always run database migrations when needed, regardless of current user role
  • Allow specifying multiple post types in KokoAnalytics\get_most_viewed_posts() and the [koko_analytics_most_viewed_posts] shortcode. Example: [koko_analytics_most_viewed_posts post_type="page,post"]
  • Limit attempts to install optimized tracking endpoint to once per hour
  • On the analytics dashboard, use the date format from WordPress settings
  • Translate day and month names (only relevant if using M, F, l or D in the date format string)
  • WP CLI command to manually run aggregation now accepts an optional --force flag. Example: wp koko-analytics aggregate --force
  • Don’t show warning about WP Cron not working properly on sites on localhost, sites ending in .local and sites containing a port number
  • Last but certainly not least, some preparatory work for event tracking… Coming soon!

1.0.39 – Aug 29, 2023

  • Update referrer blocklist
  • Update third-party JS dependencies
  • Bump tested WordPress version

1.0.38 – Apr 25, 2023

  • Fix issue with dashboard widget rendering incorrectly when it was initially hidden.
  • Only render chart in dashboard widget when it is currently visible.

1.0.37 – Dec 07, 2022

  • Fix potential issue in tracking script causing incorrect stats collection.

1.0.36 – Dec 06, 2022

  • Shrink size of tracking script to 985 bytes (when using gzip compression).

1.0.35 – Oct 21, 2022

  • You can now call koko_analytics.trackPageview( postId ) to manually track a pageview. This is especially useful for Single Page Applications.
  • Update referrer blocklist.
  • If referrer URL is on referrer blocklist, the entire request is now ignored (vs. just the referrer part).
  • Update JavaScript dependencies.

1.0.34 – Sep 19, 2022

  • Track visits to front page (if not a static page) as well.
  • Use gmdate() for determining whether to send cache headers.
  • Update JavaScript dependencies.

1.0.33 – Aug 17, 2022

  • Always show at least 1 visitor if pageviews were recorded that day.
  • Decrease Cache-Control header of REST API responses to 60s.
  • Add button to reset all statistics.
  • Add filter koko_analytics_url_aggregations to modify or add URL aggregations for referrer URL’s.
  • Created an initiative on OpenCollective for others to help fund development and support costs of Koko Analytics. Please visit https://opencollective.com/koko-analytics for more details.

1.0.32 – Jun 2, 2022

  • Fix error in latest release by ensuring Endpoint_Installer class is always loaded when needed.

1.0.30 – Jun 1, 2022

  • Delete option koko_analytics_use_custom_endpoint on plugin uninstall.
  • Only load dashboard-widget.js if user has required capability for viewing stats.
  • Add constant KOKO_ANALYTICS_CUSTOM_ENDPOINT for disabling the custom endpoint entirely. This filter can also be used to manually install the endpoint file to a different file location.
  • Re-attempt installation of the custom endpoint file every hour. This also automatically re-tests whether the custom endpoint is still working as expected. The plugin already did this whenever you visited the dashboard page, but now it simply runs more often and without requiring you to log-in to your WordPress admin.

1.0.29 – Jan 25, 2022

  • Skip empty …