Analytics setup¶
How to wire optional data sources into the public analytics dashboard.
Already automatic¶
These run weekly via .github/workflows/analytics.yml and on every docs deploy:
| Source | Script | Auth |
|---|---|---|
| PyPI downloads | pypistats_snapshot.py |
None |
| GitHub Traffic | gh api |
GITHUB_TOKEN |
| Public mentions | mentions.py |
None |
| Dashboard HTML | dashboard.py --site |
None |
BigQuery (PyPI country breakdown)¶
Gives per-country install counts (pip/poetry/uv only, mirrors filtered).
- Create a GCP project and enable BigQuery.
gcloud auth application-default login- Run once locally:
- For CI: create a service account with
bigquery.jobUser+bigquery.dataViewer, add JSON key as repo secretGCP_SA_KEY.
Snapshots land in analytics/snapshots/bigquery/.
GoatCounter (docs referrers + countries)¶
The docs site loads GoatCounter from docs/javascripts/analytics.js. Subdomain is audiobench.
- Sign up at goatcounter.com.
- Create API token (Settings → API).
- Add repo secret
GOATCOUNTER_API_TOKEN(and optionallyGOATCOUNTER_SITE=audiobench).
Google Search Console (search queries)¶
Shows which Google queries drive traffic to audiobench.dev.
- Verify the property in Search Console.
- Create a service account, add it as a user on the property.
- Download JSON key →
GOOGLE_APPLICATION_CREDENTIALS=/path/key.json - Set
GSC_SITE_URL(e.g.sc-domain:audiobench.devorhttps://thenirock.github.io/audiobench/).
Verification can take 24–48 hours before data appears.
CLI telemetry worker (opt-in usage)¶
Deploy the Cloudflare Worker in infra/telemetry/:
cd infra/telemetry
wrangler d1 create audiobench-telemetry
# paste database_id into wrangler.toml
wrangler d1 execute audiobench-telemetry --remote --file=schema.sql
wrangler deploy
Set AUDIOBENCH_TELEMETRY_URL in releases if you use a custom hostname. The dashboard reads AUDIOBENCH_TELEMETRY_SUMMARY_URL (defaults to /v1/summary on the same host).
Refresh the published dashboard¶
python scripts/analytics/mentions.py
python scripts/analytics/dashboard.py --site
mkdocs gh-deploy --clean
Or wait for the Monday cron / the docs workflow on push to main.