=== Koko Analytics ===
Contributors: Ibericode, DvanKooten
Donate link: https://wordpress.org/support/plugin/koko-analytics/reviews/#new-post
Tags: analytics, statistics, stats, privacy, counter
Requires at least: 6.0
Tested up to: 6.6
Stable tag: 1.3.13
License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Requires PHP: 7.3
Privacy-friendly and efficient analytics for your WordPress site
== Description ==
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.
### Features
- **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 850 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](https://github.com/ibericode/koko-analytics) 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](https://wordpress.org/plugins/amp/) only).
### Pro features
The following features are available through [Koko Analytics Pro](https://www.kokoanalytics.com/pricing):
- **Event Tracking**: Built-in events like outbound link clicks, form submissions plus the ability to [track any type of custom event](https://www.kokoanalytics.com/kb/tracking-events/).
- **Email reports**: Daily, weekly or monthly [email reports](https://www.kokoanalytics.com/2024/08/21/setting-up-email-reports-with-koko-analytics-pro/).
### Contributing
You can contribute to Koko Analytics in many different ways. For example:
- [Purchase Koko Analytics Pro](https://www.kokoanalytics.com/pricing/)
- Write about the plugin on your blog or share it on social media.
- [Review the plugin here on WordPress.org](https://wordpress.org/support/plugin/koko-analytics/reviews/#new-post)
- [Translate the plugin into your language](https://translate.wordpress.org/projects/wp-plugins/koko-analytics/stable/) using your WordPress.org account.
- [Vote on feature suggestions in our idea board](https://github.com/ibericode/koko-analytics/discussions/categories/ideas?discussions_q=is%3Aopen+sort%3Atop+created%3A%3E%3D2022-10-25+category%3AIdeas)
== Installation ==
You can install Koko Analytics in multiple ways:
- In your WordPress admin area, go to **Plugins > New Plugin**, search for **Koko Analytics** and click **Install now**.
- [Download the latest version from WordPress.org](https://downloads.wordpress.org/plugin/koko-analytics.zip) and extract the files into your `/wp-content/plugins/` directory.
- [Download the latest release from GitHub](https://github.com/ibericode/koko-analytics/releases) and extract the files into your `/wp-content/plugins/` directory.
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**.
== Frequently Asked Questions ==
#### 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.
[https://www.kokoanalytics.com/kb/does-koko-analytics-use-cookies/](https://www.kokoanalytics.com/kb/does-koko-analytics-use-cookies/)
### 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.
[https://www.kokoanalytics.com/kb/will-koko-analytics-slow-down-my-website/](https://www.kokoanalytics.com/kb/will-koko-analytics-slow-down-my-website/)
### Is the code for this plugin on GitHub?
Yes, see [github.com/ibericode/koko-analytics](https://github.com/ibericode/koko-analytics).
### Where can I find more documentation?
Have a look at the [Koko Analytics knowledge base](https://www.kokoanalytics.com/kb/).
### 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"]
`
### How can I help fund Koko Analytics?
You can [purchase Koko Analytics Pro](https://www.kokoanalytics.com/pricing/) to help fund the plugin.
== Screenshots ==
1. Koko Analytics' dashboard to view your website statistics.
2. The settings page where you can exclude certain user roles from being counted.
3. A widget to show your most viewed posts (or any other post type) for a given period.
4. The dashboard widget to quickly show your site visits over the last 2 weeks.
== Changelog ==
#### 1.3.13 - Sep 17, 2024
- Ensure `Stats::get_totals` always returns a valid object.
- Escape return values from `add_query_arg` to prevent reflected XSS attacks.
- Use correct IP address even if client is behind proxy.
- Various minor template performance improvements.
#### 1.3.12 - Aug 18, 2024
- Fix double pageview counts introduced in version 1.3.11.
- Fix same-site showing up as referrer
#### 1.3.11 - Aug 16, 2024
- Only use referrer detection for determining returning visitors if cookie is disabled.
- Add referrer aggregation rule for Brevo email campaign links.
- Add referrer aggregation rule for Reddit links.
- Add filter hook for easily adding or modifying Koko Analytics settings.
- Add action hook for adding settings to Koko Analytics.
- Explicitly get rid of all ES6 code in tracking script.
#### 1.3.10 - Jun 20, 2024
- Registration for [Koko Analytics Pro](https://www.kokoanalytics.com/pricing/) is open again. Purchase a license if you need custom event tracking or would just like to support the plugin.
- Ignore requests from Facebook link previews and requests without a `User-Agent` HTTP header.
- Update referrer blocklist.
#### 1.3.9 - May 31, 2024
- Fix Webpack issue with tracking script.
#### 1.3.8 - May 29, 2024
- Add setting to exclude views from IP addresses.
- Show exact number of pageviews and visitors on hover.
- Use an optimized custom autoloader.
- Verify shortcode arguments for `[koko_analytics_counter]` shortcode.
- Fix error when using SQLite about ambiguous column name.
- Fix realtime pageview count using wrong duration.
#### 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](https://github.com/ibericode/koko-analytics/blob/master/code-snippets/modify-dashboard-widget/README.md).
- 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](https://github.com/ibericode/koko-analytics/blob/master/code-snippets/change-chart-colors.php).
- 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](https://www.kokoanalytics.com/2023/10/31/speeding-up-dashboard-removing-react-vanilla-js/) 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 `