﻿=== No Cookie Analytics – By Arfa ===
Contributors: arfarehman
Tags: analytics, gdpr, tracking, privacy, no cookies
Requires at least: 6.2
Tested up to: 7.0
Stable tag: 1.0.9
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Privacy-focused analytics with server-side tracking, dashboard reports, and no frontend cookies.

== Description ==
No Cookie Analytics – By Arfa tracks visits server-side without setting cookies in visitors'
browsers. Data stays in your WordPress database with an admin dashboard, reports, and optional
CSV export.

== Privacy ==
This plugin stores analytics records in your WordPress database (`wp_ncaba_hits`), including:

* Page URL/path
* Referrer host
* Browser/OS/device type
* Anonymized IP hash
* Session key
* Country code
* Whether the request resulted in a 404 (not found)
* UTM campaign parameters (utm_source, utm_medium, utm_campaign), when present in the visited URL
* Timestamp

No raw IP address is stored in the plugin database.

Country detection behavior:

1. Uses server-provided geolocation headers when available (for example Cloudflare or GeoIP
   headers).
2. Optional external IP geolocation lookup can be enabled by admin consent in plugin settings.

When external geolocation is enabled, visitor IP is sent to:

* Service: [ipapi.co](https://ipapi.co/) (primary) and [ipwho.is](https://ipwho.is/) (fallback)
* Purpose: country lookup only

Site owners must disclose this in their privacy policy before enabling external lookup.

== External services ==

This plugin can optionally use the third-party services ipapi.co and ipwho.is for country lookup. The lookup
is **disabled by default** and only runs after a site administrator explicitly enables the
"Allow External Geo Lookup" option in plugin settings.

* Services: ipapi.co (https://ipapi.co/) and ipwho.is (https://ipwho.is/) as fallback
* What is sent: the visitor's IP address (only when the option is enabled and no server-provided
  geo headers are available).
* When: at most once per visitor IP per week on success; failed lookups are retried after one hour.
* Why: to determine the visitor's country code for the analytics dashboard.
* ipapi.co Terms of Service: https://ipapi.co/terms/
* ipapi.co Privacy Policy: https://ipapi.co/privacy/
* ipwho.is Terms: https://ipwhois.io/terms
* ipwho.is Privacy: https://ipwhois.io/privacy

If the option is left disabled, the plugin never contacts ipapi.co or ipwho.is.

== Features ==
* Server-side tracking
* GDPR-aware design (configure to your legal requirements)
* No frontend cookies
* Admin dashboard and home screen widget
* Pages, Referrers, Users, 404, and Campaigns (UTM) reports
* Per-post analytics meta box in the editor sidebar
* CSV export and settings import/export
* Local bundled frontend assets (no CDN required)

== Installation ==
1. Upload the `no-cookie-analytics-by-arfa` folder to `/wp-content/plugins/` (or install through the
   WordPress plugin installer).
2. Activate the plugin through the **Plugins** screen.
3. Open the **Analytics** menu in the admin area.

== Frequently Asked Questions ==

= Does this plugin set cookies? =

No. Tracking is performed on the server when pages are requested.

= Where is data stored? =

In a custom table in your WordPress database (`wp_ncaba_hits` by default).

== Changelog ==

= 1.0.9 =
* Redesigned the admin dashboard and reports with a refreshed blue accent color and plain CSS only (no
  external framework, so there's no risk of conflicting with other plugins' styles). Charts (visitors trend,
  page views trend, country donut) now animate on load/refresh with styled tooltips.
* Redesigned KPI stat tiles with period-over-period percentage change badges, comparing each metric to the
  immediately preceding period of equal length (e.g. this week vs. last week).
* Added a "Page Views Overview" chart alongside Visitors Overview, showing total tracked page views over the
  selected range (as opposed to unique visitors).
* Added a 404 Report (Analytics → 404 Report) listing missing pages visitors hit, with hit counts and
  last-seen times, to help find broken links to fix or redirect.
* Added a per-post Analytics meta box in the editor sidebar (Posts, Pages, and other public post types),
  showing total views, unique visitors, a 30-day change badge, a 14-day views sparkline, and the post's top
  referrers.
* Added UTM campaign tracking (`utm_source`, `utm_medium`, `utm_campaign`) with a new Campaigns Report
  (Analytics → Campaigns Report) showing visits and visitors grouped by source, medium, and campaign.
* Dashboard grid now uses responsive layout classes instead of inline styles, so cards stack properly on
  narrow screens instead of being squeezed. Report tables now scroll horizontally on small screens instead
  of overflowing the page. Settings screen now uses the same card layout and typography as the rest of the
  plugin.
* KPI stat tiles and the realtime counter now animate ("count up") when values change instead of jumping
  instantly. Added a subtle live-activity pulse indicator to the Realtime card and dashboard widget.
* Fixed the WordPress Dashboard "Quick View" widget never loading its stylesheet (it only loaded on the
  plugin's own admin screens), so the widget now renders styled instead of as plain unstyled text.
* Fixed the bounce-rate "quality" tag not updating color after a live dashboard refresh, and a color-palette
  mismatch between the initial server-rendered country legend and the JS-rendered legend after a refresh.
* Moved front-end tracking from the `init` hook to `template_redirect` so conditional tags like `is_404()`
  and `get_queried_object_id()` are reliable at tracking time — the main query hasn't run yet at `init`. This
  also improves `post_id` tracking accuracy used by the new per-post meta box.
* Added `is_404`, `post_id` (indexed), and `utm_source`/`utm_medium`/`utm_campaign` (indexed) columns to the
  hits table to support the new reports and meta box.

= 1.0.8 =
* Dashboard: redesigned info tooltips to use Dashicons with cleaner markup and tooltip text via CSS `::after`.
* Dashboard: Visitors Overview chart now shows hourly data when the "Last 24 hours" filter is selected.
* Fixed hourly chart data accuracy by bucketing visits in the WordPress site timezone.
* Improved country detection with more server geo headers, better proxy IP resolution, and optional
  external lookup via ipapi.co with ipwho.is fallback (removed browser-language country guessing).
* Fixed recent activity timestamps by storing hits in site time and formatting relative times correctly.
* Settings: added role-based tracking exclusion with a custom searchable multiselect when "Skip tracking
  for logged-in users" is enabled.
* Admin notices (including warnings) now render before the analytics layout wrapper to avoid layout issues.
* Tracking now records page paths with query strings (for example `/blog?123456`) as separate entries in reports.

= 1.0.7 =
* Removed UTF-8 byte order marks (BOM) from PHP sources so activation no longer sends accidental
  output to the browser.
* Uninstall: reliable table drop, clear all related and legacy cron hooks, and remove cached
  geo lookup transients.
* Deactivation: clear legacy cleanup cron hook names in addition to the canonical event.

= 1.0.6 =
* Renamed plugin to "No Cookie Analytics – By Arfa"; text domain and translation template are
  `no-cookie-analytics-by-arfa` (Domain Path: `/languages`).
* Main bootstrap file is `no-cookie-analytics-by-arfa.php`; directory slug `no-cookie-analytics-by-arfa`.
* PHP class and constant prefix `NCABA_*` (e.g. `NCABA_VERSION`, `NCABA_Activator`); runtime
  identifiers use lowercase `ncaba_*` / `ncaba-` (database table `{prefix}ncaba_hits`, options,
  hooks, AJAX, and asset handles). Legacy `cfaba_*`, `cfba_*`, and mistaken `NCABA_*` option keys
  or table names migrate automatically on upgrade.
* Plugin URI points to a reliable HTTPS profile page; localized admin strings and dashboard JS
  escaping improvements.
* Bumped tested-up-to header for current WordPress.

= 1.0.5 =
* Previous branding and slug iteration; see older releases for detail.

= 1.0.4 =
* Raised minimum WordPress version to 6.2 for safe `%i` identifier placeholders in
  `$wpdb->prepare()`.
* Hardened admin and cron SQL (prepared statements, `esc_like()` for `LIKE` patterns).
* Replaced `parse_url()` with `wp_parse_url()`; removed redundant `fclose()` on export stream.
* Settings import notices use per-user transients; validated upload temp files with
  `is_uploaded_file()`.
* Added readme short description; direct-access guard on settings view template.

= 1.0.3 =
* Bundled Chart.js and Poppins assets locally (removed CDN dependency).
* Added explicit admin consent toggle for external geolocation lookup.
* Updated privacy disclosure and reviewer-oriented readme details.

= 1.0.2 =
* Improved admin UI and tooltip behavior.

= 1.0.1 =
* Added richer visitor identity and dashboard/report improvements.

= 1.0.0 =
* Initial release.
