=== Crustat ===
Contributors: _smartik_
Tags: analytics, statistics, stats, visitors, privacy
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

See who visits your site, where they come from and which pages they read, right here in WordPress. Simple analytics, set up in a minute.

== Description ==

**Crustat** is simple web analytics. It tells you how your site is doing in plain words, without a wall of charts to decode.

This plugin connects your WordPress site to your [Crustat](https://crustat.com) account. Click **Connect to Crustat**, pick your site, and your stats show up in WordPress on the **Crustat** page, with a summary on your WordPress Dashboard. You don't touch your theme or any code.

= What you see =

* **Visitors and page views**, day by day, with a short plain-language summary of how the week went.
* **Where people come from**: search engines, social networks, other sites that link to you, and campaigns.
* **Your top pages**, and the pages people land on first.
* **Countries, devices and browsers**, so you know who your readers are.
* **Clicks on outside links**, email and phone links, so you see which ones people use.

Your stats are in WordPress on the **Crustat** page, and in your Crustat dashboard at [app.crustat.com](https://app.crustat.com), where you can check them from any device.

= Light on your site =

The Crustat script is tiny, smaller than a single small image, and loads without holding up your pages. The plugin adds one line to your pages and nothing else: no extra database tables, no heavy admin screens.

= Your own visits are left out =

By default, visits from you and your team (anyone who can write or edit posts) aren't counted while you're logged in, so your numbers show real readers. You can turn this off under Settings on the Crustat page.

= Works with caching plugins =

The plugin tells popular caching and speed plugins (WP Rocket, Autoptimize, LiteSpeed Cache, SiteGround Optimizer, WP-Optimize, Perfmatters, Hummingbird and Jetpack Boost) to leave the Crustat script alone, so it keeps counting after they optimize your pages. It also works with Cloudflare Rocket Loader.

= You need a Crustat account =

Crustat is a service: the plugin sends visits to Crustat, and you read your stats in the Crustat dashboard. Every account starts with a 14-day free trial, no card needed. [Create your account](https://app.crustat.com).

== External services ==

This plugin connects your site to Crustat, the analytics service it's built for. Without it, the plugin does nothing.

**What loads, and when:** while your site is connected, every front-end page of your site loads the Crustat script from https://stats.crustat.com/script.js. Nothing loads or is sent before you connect or after you disconnect. It doesn't load in wp-admin, in feeds, or for logged-in team members when "Don't count visits from your team" is on.

**What the script sends to Crustat** (to https://stats.crustat.com, each time a page is viewed, left, or an outside link is clicked):

* the address of the page being viewed, and the address of the page the visitor came from (the referrer);
* the width of the visitor's browser window;
* your site ID;
* how long the page was visible, sent when the visitor leaves or switches tabs;
* when a visitor clicks a link to another site, an email (mailto:) link or a phone (tel:) link, that link's address.

Crustat's server also reads the country, browser and device type from the request. It tells visitors apart with an anonymous code made from that day's random salt, your site, the visitor's IP address and their browser, so the same person shows up once per day and can't be followed across days or sites. The IP address is never stored.

The script sets no cookies and writes nothing to the visitor's browser. It only reads one flag that a site owner can set on their own browser to leave out their own visits.

The script skips visits from localhost. The plugin sends nothing to Crustat until an administrator clicks Connect to Crustat. From wp-admin it then talks to https://app.crustat.com, with no visitor data: it registers this site with Crustat, exchanges and refreshes the connection, fetches the stats shown in wp-admin, and cancels the connection when you disconnect or delete the plugin.

**When you connect, and while you view your stats in WordPress** (to https://app.crustat.com):

* when you click Connect to Crustat: your site's name, its home address, and the address of its Crustat page in wp-admin, so Crustat knows where to send you back; then your browser goes to Crustat, where you sign in and pick the site to show;
* after you allow it: a one-time code is exchanged for access tokens, which the plugin keeps encrypted in your WordPress database and never shows in the browser;
* while you look at the Crustat page or the Dashboard widget: requests for your site's stats, signed with that token. WordPress asks Crustat; your browser gets the stats from your own site;
* when you disconnect or delete the plugin: a request that ends the connection at Crustat.

**Pictures on the Crustat page** (loaded by your browser): country flags and browser and system logos come from https://cdn.crustat.com, and each request names the country code or the browser or system (for example `/flags/de.svg`). The icons of the sites your visitors came from come from https://api.crustat.com/favicon/, and each request names that site's domain (for example `/favicon/github.com`). Like any picture on a web page, these requests also carry your browser's IP address and browser details.

This service is provided by Crustat: [Terms of Service](https://crustat.com/terms), [Privacy Policy](https://crustat.com/privacy).

== Source code ==

The stats screens in WordPress are compiled JavaScript (in the plugin's `build/` folder). The readable source for them is included in the plugin's `source/` folder, together with the build setup (`package.json`, `package-lock.json`, and `wordpress/plugin/webpack.config.js`). To rebuild them, open `source/` and run `npm install`, then `npm run build` (with Node.js 22). The rebuilt files land in `source/wordpress/plugin/build/`.

The plugin bundles the Nunito, Fraunces and JetBrains Mono fonts, all under the SIL Open Font License 1.1 (the license text is in `assets/fonts/OFL.txt`).

== Installation ==

1. In your WordPress dashboard, go to **Plugins → Add New**, search for **Crustat**, then install and activate it.
2. Go to **Crustat** in the admin menu and click **Connect to Crustat**.
3. Sign in to Crustat (or start your free trial) and pick the site to show.

That's it. Your stats show on the Crustat page.

== Frequently Asked Questions ==

= Why can't I connect? =

Connecting needs your WordPress admin on https (Crustat only sends you back to a secure address). If your admin address starts with http://, turn on https with your host, then connect.

= Who can see the stats in WordPress? =

Administrators. A developer can let other roles see them with the `crustat_stats_capability` filter; connecting and disconnecting stay with administrators.

= Do I need to edit my theme? =

No. Once your site is connected, the plugin adds Crustat to every page for you.

= Why don't I see my own visits? =

While you're logged in as someone who can write or edit posts, your visits aren't counted, so your numbers show real readers. To check that counting works, open your site in a private window. To count logged-in team members too, turn off "Don't count visits from your team" under Settings on the Crustat page.

= Does Crustat use cookies? =

No. Crustat sets no cookies and stores nothing on your visitors' devices. Visitors are told apart on Crustat's server by an anonymous code made from that day's random salt, your site, the visitor's IP address and their browser. The salt changes every day and is then deleted, so the same person shows up once per day and can't be followed across days or sites. The IP address is never stored. So Crustat itself needs no cookie banner. Other tools on your site, like ad pixels, embedded videos or chat widgets, may still set cookies of their own.

= I use a caching or speed plugin. Do I need to change anything? =

Usually not. The plugin asks WP Rocket, Autoptimize, LiteSpeed Cache, SiteGround Optimizer, WP-Optimize, Perfmatters, Hummingbird and Jetpack Boost to leave the Crustat script alone, and adds the setting Cloudflare Rocket Loader needs. If you use a different plugin that combines, delays or defers scripts and visits don't show up, exclude `stats.crustat.com/script.js` in its settings. After changing caching settings, clear your cache.

= Will it slow down my site? =

No. The script is tiny and loads after your page is ready to read.

= Does it work on multisite? =

Yes. Activate it on each site you want to count, and connect each one to its own Crustat site.

== Changelog ==

= 1.0.0 =
* Initial release: connect your site to your Crustat account and see your stats in WordPress, on a Crustat page and in a Dashboard widget.
* Leave out your team's visits, and keep caching plugins from breaking the script.
* Light and dark colours, remembered for each person.
