You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit dc6fd34
Browse filesBrowse the repository at this point in the historyBrowse files
Count page views and empty searches with GoatCounter (#120)
The maintainer chose GoatCounter to learn which searches find nothing.
- site/public/count.js is a small self-hosted counter that sends
GoatCounter's documented /count hits with sendBeacon: page path
(no query string), title and referrer, plus named events. No
cookies, storage or identifiers; nothing is sent under Do Not Track,
Global Privacy Control, automation, localhost or file://.
- Every page loads it deferred. script-src stays 'self'; the CSP opens
connect-src to the counter's origin only (shared.mjs
ANALYTICS_ENDPOINT). The service worker precaches it.
- The catalog reports a view once it has settled for two seconds, and
each event once per page load (search.mjs viewEvents): the filter
combination, and a search with no results (query lowercased and cut
to 40 characters, with its filters).
- The footer and a new README Privacy section say what is collected.
Tests cover the event names, the CSP and the script tag. Checked in a
browser on a local build: an empty search is reported once, a search
with results is not, nothing is sent from localhost, and the console
shows no CSP errors.
Fixes#120
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -262,6 +262,10 @@ recorded about it and how to correct it or remove its preview.
262
262
Please follow the [Code of Conduct](CODE_OF_CONDUCT.md). Local commands and the repository
263
263
layout are in [CONTRIBUTING.md](CONTRIBUTING.md#repository-layout).
264
264
265
+
## Privacy
266
+
267
+
The website counts usage with [GoatCounter](https://www.goatcounter.com/), so the catalog can see which searches find nothing and add what is missing. It sends the page path, title and referrer on each page view, plus two kinds of named event from the catalog: a search that found no results (the query, lowercased and cut to 40 characters) and the set of filters used. There are no cookies, no local storage and no identifiers, and the counter script is served from this site. Nothing is sent when the browser has Do Not Track or Global Privacy Control turned on, or when the site runs locally. The code is [`site/public/count.js`](site/public/count.js).
268
+
265
269
## Support
266
270
267
271
If the catalog saves you time, you can [sponsor TMHSDigital on GitHub](https://github.com/sponsors/TMHSDigital). Entirely optional.
eq("a query with results sends nothing",JSON.stringify(viewEvents({ ...URL_DEF,q: "pixel"},URL_DEF,12)),JSON.stringify([]));
1081
+
eq("a query with no results is sent normalised",JSON.stringify(viewEvents({ ...URL_DEF,q: " Voxel TREES "},URL_DEF,0)),JSON.stringify(["no-results/voxel trees"]));
1082
+
eq("the query is cut to 40 characters",viewEvents({ ...URL_DEF,q: "x".repeat(90)},URL_DEF,0)[0].length,"no-results/".length+40);
1083
+
eq("filters are sent without the query",JSON.stringify(viewEvents({ ...URL_DEF,q: "tree",category: "2d"},URL_DEF,3)),JSON.stringify(["filters/cat=2d"]));
1084
+
eq("no results with filters names both",JSON.stringify(viewEvents({ ...URL_DEF,q: "tree",category: "2d"},URL_DEF,0)),JSON.stringify(["filters/cat=2d","no-results/tree [cat=2d]"]));
1085
+
eq("CSP connects only to the counter's origin",CSP.includes(`connect-src 'self' ${newURL(ANALYTICS_ENDPOINT).origin};`),true);
Copy file name to clipboardExpand all lines: site/lib/shared.mjs
+7-1Lines changed: 7 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -283,6 +283,7 @@ export function siteFooterHtml({ root, stamp, total, credit = true, current = nu
283
283
return`<footer class="footer">
284
284
<p>Catalog metadata is CC0. Linked assets keep their own licences. This is the catalog's reading of each licence, not legal advice: re-check the live source before shipping.</p>
<p class="footer-privacy">Page views and searches that find nothing are counted with GoatCounter: no cookies, nothing that identifies you, and nothing is sent when your browser asks not to be tracked.</p>
0 commit comments