=== trackd.one – Privacy-friendly Analytics ===
Contributors: mignutimedia, eduardditler
Tags: analytics, privacy, statistics, woocommerce, gdpr
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.3.4
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Cookieless, privacy-friendly analytics for WordPress and WooCommerce: pageviews, revenue, form submissions, downloads – no cookies, no fingerprinting.

== Description ==

trackd.one is a lightweight, privacy-friendly analytics service – an alternative to
Google Analytics in the spirit of Plausible and Umami, hosted on Cloudflare. This
plugin connects your WordPress site to your trackd.one account: enter your Website
ID and you are done – no theme editing, no code.

**What you get**

* **Pageviews, visitors, referrers, UTM campaigns, countries, devices** – in a clear
  real-time dashboard at trackd.one.
* **Tiny script** – under 2 KB (gzip), loaded with `defer`, it never blocks rendering.
* **No cookies, no local storage, no fingerprinting** – visitors are counted with a
  daily-rotating, salted hash; raw IP addresses are never stored.
* **Respects opt-outs** – Global Privacy Control and Do Not Track are honoured by the
  script itself.
* **Your team stays out of the numbers** – logged-in roles you choose (default:
  administrators and editors) are not tracked. Previews, the customizer, feeds and
  the admin area are never tracked.
* **WooCommerce shop analytics** – each order is reported once from the order-received
  page (total, currency, order number, order lines); unpaid orders (e.g. bank transfer)
  as pending. Product views, add to cart and checkout feed the shop funnel, cart
  abandonment and per-product reports. With an API key that may change order status,
  payments, cancellations and refunds are synced automatically. Compatible with
  High-Performance Order Storage (HPOS).
* **Automatic events** – form submissions (Contact Form 7, WPForms, Elementor Pro
  forms), file downloads (PDF, ZIP, Office files, media, installers) and clicks on
  outbound links. Only the form ID, the file address or the link target (host and path,
  no query string) are sent – never what visitors type into a form.
* **Core Web Vitals and heatmaps** (optional) – real-user LCP, CLS, INP, FCP and TTFB,
  and click positions for heatmaps.
* **Consent integration** (optional) – with the WP Consent API, the script is only
  loaded after the visitor consented to "statistics" in your consent banner.
* **Proxy mode** (optional) – serves the script and tracking requests through your own
  site, so ad blockers that block analytics hosts do not hide your visitors.
* **Dashboard widget** – visitors, pageviews and top pages of the last 7 days on your
  WordPress dashboard (needs an API key, Pro plan or above).

You need a trackd.one account. Every new account starts with a free 7-day trial of all
Business features – no credit card, nothing is booked automatically. Plans (Pro from
€9/month incl. VAT) are listed at https://trackd.one/en/pricing/. Sign up at
https://trackd.one/app/register.

== Installation ==

1. Install the plugin through **Plugins → Add New** (search for "trackd.one"), or
   upload the ZIP via **Plugins → Add New → Upload Plugin**, then activate it.
2. In the trackd.one dashboard, add your website (its domain must match your WordPress
   domain) and copy the **Website ID** from Settings → Install.
3. In WordPress go to **Settings → trackd.one**, paste the Website ID and save.

That's it – open your site in a private window and you will see the visit in the
trackd.one real-time view within seconds.

Optional: add an API key (Account → API keys in trackd.one, Pro plan or above) for the
dashboard widget, and a proxy key (website → Settings → Install → WordPress) for proxy
mode.

== Frequently Asked Questions ==

= Do I need a trackd.one account? =

Yes. The plugin sends your site's statistics to your trackd.one account, where you view
them. You can try every Business feature free for 7 days without a credit card; see
https://trackd.one/en/pricing/ for the plans.

= Does trackd.one use cookies? =

No. trackd.one sets no cookies and stores nothing in the visitor's browser (no local
storage, no session storage). It does not use fingerprinting. Visitors are counted with
a hash of the IP address, a server-side secret, the date and the website, which
changes every day; the raw IP address is never stored.

= Is it GDPR compliant? Do I still need a consent banner? =

trackd.one is built for data minimisation: no cookies, no device storage, no
fingerprinting, no cross-site tracking, IP addresses only processed transiently for
the daily-salted hash. A data processing agreement (Art. 28 GDPR) is available at
https://trackd.one/en/legal/dpa/. Whether your
site needs consent for analytics depends on your setup and jurisdiction – that
assessment is up to you as the site operator. If you decide to ask for consent, enable
**Settings → trackd.one → Consent** and use a consent banner that supports the WP
Consent API: the script is then only loaded after the visitor accepts "statistics".
Mention trackd.one in your privacy policy (see the trackd.one privacy policy linked
below for the data processed).

= Which consent banners work with the consent option? =

Any consent plugin that implements the WP Consent API (for example Complianz,
CookieYes, Cookiebot, Real Cookie Banner and others that integrate with it). The WP
Consent API plugin must be active. If it is not, the script is not loaded at all while
the consent option is on.

= Are my own visits counted? =

Not by default: logged-in administrators and editors are excluded. You can change the
roles under **Settings → trackd.one → Exclude roles**.

= How is WooCommerce revenue tracked? =

When a customer reaches the order-received page, the plugin reports one `purchase` event
with the order total, currency, order number and order lines (product ID or SKU, name,
category, price, quantity – no customer data). The order is marked so a reload does not
count it twice, and trackd.one counts every order number only once. Paid orders
("processing" or "completed") count as revenue right away; unpaid ones (pending, on hold –
e.g. bank transfer) are shown as pending until they are paid.

Payment status, cancellations and refunds: enter an API key with the option "May change
order status" (trackd.one → Account → API keys) in the API key field. The plugin then
reports these changes in the background. Without such a key you can change the status in
the trackd.one order list.

On product pages the plugin sends `view_item`, on "Add to cart" `add_to_cart` and on the
checkout page `begin_checkout`. You see revenue, the shop funnel, products and orders in
the trackd.one dashboard under Revenue.

= Which form plugins are supported? =

Contact Form 7 (event after a successful send), WPForms (AJAX and classic submissions)
and Elementor Pro forms. The event `form_submit` carries the form ID, e.g. `cf7-123` or
`wpforms-45`. No field contents are sent.

= What is proxy mode and when should I use it? =

Some ad blockers block requests to analytics hosts. In proxy mode the script and the
tracking requests go to your own site (`/wp-json/tdo/v1/…`) and WordPress forwards them
to trackd.one. While forwarding, your server sees the visitor's IP address for a moment
and passes it on (it is not stored by the plugin) so trackd.one can compute the
daily-rotating visitor hash. For rate limiting (120 requests per minute and visitor)
the plugin counts requests under a salted hash of the IP address for one minute in the
object cache; without a persistent object cache it only stores that hash for one minute
when trackd.one throttled the visitor. If
your site is behind Cloudflare or another CDN, enable "Site is behind a proxy/CDN" so
the real visitor IP and country are used: CF-Connecting-IP is only trusted for requests
from Cloudflare's addresses, otherwise the last X-Forwarded-For entry (or X-Real-IP) is
used. Only enable it if every request passes through that proxy – otherwise visitors
could fake these headers. Without a country header the country stays unknown. If
trackd.one cannot be reached, your pages stay fast: forwarding uses short timeouts,
tracking requests are dropped for a minute and the script is served from the last good
copy. Proxy mode needs a proxy key that you create in the trackd.one dashboard and adds
a little load to your server.

= The dashboard widget shows "Pro plan" – why? =

The widget reads your numbers through the trackd.one Read API, which is available on
the Pro plan and above. Tracking itself works on every plan.

= Does it work with caching plugins? =

Yes. The script tag is the same for all visitors, so cached pages track normally. The
excluded roles apply to logged-in users, whose pages caching plugins usually do
not cache. After changing settings, clear your page cache.

= Can I use my own trackd server? =

Yes – set **Advanced → Server URL** to your server. The URL must use https://; http://
is only accepted for localhost and 127.0.0.1 (local testing). Servers in private
networks (e.g. 10.x.x.x, 192.168.x.x or intranet host names) are refused unless you add
`define( 'TRACKD_ALLOW_LOCAL_SERVER', true );` to wp-config.php. On multisite only
network administrators can change the server URL. The plugin never follows redirects
from the server, so keys are never sent to another host.

== External services ==

This plugin connects your site to **trackd.one**, a web analytics service operated by
Mignuti Media – Eduard Ditler, Germany. The service is required for the plugin to work;
nothing is sent before you enter a Website ID.

**On your front-end pages (visitors)**

* **Tracking script** – `https://trackd.one/t.js` is loaded on every tracked page (in
  proxy mode it is served from your own site, which fetches it from trackd.one at most
  once per hour). With Web Vitals enabled, `https://trackd.one/sdk/vitals.js` is loaded
  as well.
* **Tracking requests** – the script sends events to `https://trackd.one/api/collect`
  (in proxy mode: to your site, which forwards them server-side). Data sent: your Website
  ID, the page URL (only UTM parameters are kept, e-mail addresses are removed), page
  title, referrer (origin and path), UTM campaign parameters, event names and their data
  (form ID, download address, outbound link target). With WooCommerce revenue enabled:
  shop events (product viewed and added to cart with product ID, name, price and quantity;
  checkout started with the cart total and currency), and for orders the order total, currency, order number, payment
  status and the order lines (product ID, name, price, quantity, category) – never the
  customer's name, address or e-mail address. Optional: Web Vitals timings and click
  positions for heatmaps. Together with every request the browser (or, in proxy mode,
  your server) transmits the visitor's IP address, user agent and language; the IP
  address is only used transiently to compute a daily-rotating salted hash and to derive
  the country and is never stored. No cookies are set and nothing is stored on the
  visitor's device.

**In the WordPress admin (administrators only)**

* **Dashboard widget** – if you add an API key, WordPress requests your statistics of
  the last 7 days from `https://trackd.one/api/v1/…` (server-to-server, cached for 10
  minutes). Data sent: the API key and your Website ID.
* **Connection check** – with an API key, the settings page asks
  `https://trackd.one/api/v1/websites` and `…/stats` whether the Website ID exists, whether
  its domain matches your site and whether pageviews arrived in the last 24 hours
  (server-to-server, cached for 10 minutes). Data sent: the API key and your Website ID.
* **Payment status sync** – with an API key, when a WooCommerce order is paid later,
  cancelled or refunded, your server sends the order number, the new status and, for
  refunds, the refunded amount to `https://trackd.one/api/v1/websites/<id>/orders/…`
  (in the background). Data sent: the API key, your Website ID and these order fields.

Service provider: Mignuti Media – Eduard Ditler, Lahnstein, Germany.
Terms of Service: https://trackd.one/en/legal/terms/ (German original: https://trackd.one/legal/agb/)
Privacy Policy: https://trackd.one/en/legal/privacy/ (German original: https://trackd.one/legal/datenschutz/)
Data Processing Agreement: https://trackd.one/en/legal/dpa/ (German original: https://trackd.one/legal/avv/)

== Screenshots ==

1. Settings → trackd.one: status card with the connection check and all enabled features, General tab (Website ID, roles and pages that are not tracked, Web Vitals and heatmaps).
2. The dashboard widget with visitors, pageviews and top pages of the last 7 days.
3. Events & shop: automatic form, download and outbound-link events, WooCommerce revenue and shop funnel, ignored test orders, custom events.
4. Privacy: load only after consent (WP Consent API) and a ready-to-copy privacy policy text.
5. Proxy mode: serve the script and tracking requests through your own site.

== Changelog ==

= 1.3.4 =
* Code hygiene from Plugin Check: escaped line-break pattern in the settings sanitizer, order key read with sanitize_text_field(), annotated core filter. No change in behaviour.

= 1.3.3 =
* Fix: the example placeholders for excluded pages and ignored test orders were always German; they are now translated.

= 1.3.2 =
* Faster admin: the connection check and the dashboard widget load after the page is shown, so a slow or unreachable trackd.one no longer delays the settings page or the dashboard.
* Proxy mode: no database writes per pageview any more. The per-visitor rate limit counts in the persistent object cache (Redis, Memcached …) when there is one; without one, only a visitor IP that trackd.one throttled is paused for a minute.
* Proxy mode: the script carries an ETag (returning visitors get a short "304 Not Modified") and is served stale while revalidating, like on trackd.one.
* The event and consent helpers are minified (events script 2.5 → 1.6 KB gzip); with SCRIPT_DEBUG the readable sources load.

= 1.3.1 =
* Fix: proxy mode on a site without HTTPS stopped all tracking (the script only sends to https:// hosts). It is now only used over HTTPS; otherwise the script keeps loading directly and the settings show "Needs HTTPS". New filter trackd_proxy_https for TLS ending at a load balancer.

= 1.3.0 =
* Connection check in the status card (with an API key): confirms that the Website ID exists, that its domain matches this site and that pageviews arrived in the last 24 hours.
* Exclude pages: paths that are not tracked ("*" for everything below, e.g. /my-account/*).
* WooCommerce: ignore test orders by billing e-mail address or @domain (compared on the site, never sent).
* Settings: "Advanced" folded into "General", the "Dashboard widget" tab is now "API key", new card "Custom events & goals", tabs follow the #anchor.

= 1.2.0 =
* New settings page: status card with all enabled features at a glance, tabs (General, Events & shop, Privacy, Dashboard widget, Proxy mode, Advanced), badges for missing keys, collapsible details and a sticky save bar.
* Privacy: suggested privacy policy text for trackd.one (copy button on the Privacy tab and in Settings → Privacy → Policy guide).

= 1.1.1 =
* WooCommerce: "Add to cart" in block-based shop pages (Product Collection, WooCommerce 9+) is now counted for the shop funnel.

= 1.1.0 =
* WooCommerce: order lines (products) with every purchase; unpaid orders (bank transfer, on hold) are reported as pending instead of being skipped.
* WooCommerce: shop funnel events view_item, add_to_cart and begin_checkout.
* WooCommerce: payments, cancellations and refunds are synced to trackd.one (needs an API key that may change order status).

= 1.0.1 =
* Fix: tracking on WordPress 6.0–6.2 (the script tag now gets its configuration there too).
* Proxy mode: short timeouts and a one-minute pause when trackd.one cannot be reached (pages stay fast), the script is served from the last good copy, per-visitor rate limit, size check before forwarding.
* Proxy mode: visitor IP from the last X-Forwarded-For entry; CF-Connecting-IP / CF-IPCountry only from Cloudflare addresses.
* Security: requests to the trackd server never follow redirects (keys are not sent to other hosts); server URL must use https (http only for localhost / 127.0.0.1), private networks only via TRACKD_ALLOW_LOCAL_SERVER; on multisite only network administrators can change it.
* WooCommerce: only paid orders (processing / completed) are reported on the thank-you page.
* Uninstall cleans up every site of a large multisite network.

= 1.0.0 =
* Initial release: tracking script with role exclusion, Web Vitals and heatmap options, WooCommerce revenue (HPOS-compatible), form/download/outbound events, WP Consent API integration, proxy mode, dashboard widget.

== Upgrade Notice ==

= 1.3.4 =
Maintenance release, no change in behaviour.

= 1.3.3 =
Translated example placeholders in the settings.

= 1.3.2 =
Faster admin pages and a lighter proxy mode (no database writes per pageview).

= 1.3.1 =
Proxy mode no longer stops tracking on sites without HTTPS.

= 1.3.0 =
Connection check, excluded pages and ignored test orders.

= 1.2.0 =
Clearer settings page with tabs and a suggested privacy policy text.

= 1.1.1 =
Block-based shop pages: add to cart is counted in the shop funnel.

= 1.1.0 =
WooCommerce shop analytics: products per order, shop funnel, pending payments and refunds.

= 1.0.1 =
Fixes tracking on WordPress 6.0–6.2, makes proxy mode resilient and hardens outgoing requests. WooCommerce: only paid orders are reported.

= 1.0.0 =
Initial release of the trackd.one plugin.
