{"id":13425059,"url":"https://github.com/arp242/goatcounter","last_synced_at":"2025-05-14T11:11:04.206Z","repository":{"id":38415658,"uuid":"188968112","full_name":"arp242/goatcounter","owner":"arp242","description":"Easy web analytics. No tracking of personal data.","archived":false,"fork":false,"pushed_at":"2025-04-11T00:11:26.000Z","size":46349,"stargazers_count":4823,"open_issues_count":55,"forks_count":209,"subscribers_count":30,"default_branch":"main","last_synced_at":"2025-04-11T01:21:25.911Z","etag":null,"topics":["analytics","go","golang"],"latest_commit_sha":null,"homepage":"https://www.goatcounter.com","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arp242.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"arp242"}},"created_at":"2019-05-28T06:31:26.000Z","updated_at":"2025-04-11T00:11:31.000Z","dependencies_parsed_at":"2023-12-06T06:24:48.798Z","dependency_job_id":"a6652b7f-70b6-4779-b3a2-843651452865","html_url":"https://github.com/arp242/goatcounter","commit_stats":{"total_commits":1732,"total_committers":50,"mean_commits":34.64,"dds":0.03406466512702078,"last_synced_commit":"e8f84cffb1edd969306eda30fa9300213ece0bb7"},"previous_names":["zgoat/goatcounter"],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arp242%2Fgoatcounter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arp242%2Fgoatcounter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arp242%2Fgoatcounter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arp242%2Fgoatcounter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arp242","download_url":"https://codeload.github.com/arp242/goatcounter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254129492,"owners_count":22019628,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["analytics","go","golang"],"created_at":"2024-07-31T00:01:03.571Z","updated_at":"2025-05-14T11:10:59.181Z","avatar_url":"https://github.com/arp242.png","language":"Go","funding_links":["https://github.com/sponsors/arp242"],"categories":["Go","Web Analytics","Apps","Repositories","Analytics \u0026 Monitoring","analytics","Uncategorized"],"sub_categories":["Packages","Analytics","Uncategorized"],"readme":"GoatCounter is an open source web analytics platform available as a (free)\nhosted service or self-hosted app. It aims to offer easy to use and meaningful\nprivacy-friendly web analytics as an alternative to Google Analytics or Matomo.\n\nThere are two ways to run this: as hosted service on [goatcounter.com][www], or\nrun it on your own server. The source code is completely Open Source/Free\nSoftware, and it can be self-hosted without restrictions.\n\nSee [docs/rationale.md](docs/rationale.md) for some more details on the *\"why?\"*\nof this project.\n\nThere's a live demo at [https://stats.arp242.net](https://stats.arp242.net).\n\nPlease consider [contributing financially][sponsor] if you're using\ngoatcounter.com to pay for the server costs.\n\n[sponsor]: http://www.goatcounter.com/contribute\n[www]: https://www.goatcounter.com\n\n\nFeatures\n--------\n- **Privacy-aware**; doesn’t track users with unique identifiers and doesn't\n  need a GDPR notice. Fine-grained **control over which data is collected**.\n  Also see the [privacy policy][privacy] and [GDPR consent notices][gdpr].\n\n- **Lightweight** and **fast**; adds just ~3.5K of extra data to your site. Also\n  has JavaScript-free \"tracking pixel\" option, or you can use it from your\n  application's middleware or **import from logfiles**.\n\n- Identify **unique visits** without cookies using a non-identifiable hash\n  ([technical details][sessions]).\n\n- Keeps useful statistics such as **browser** information, **location**, and\n  **screen size**. Keep track of **referring sites** and **campaigns**.\n\n- **Easy**; if you've been confused by the myriad of options and flexibility of\n  Google Analytics and Matomo that you don't need then GoatCounter will be a\n  breath of fresh air.\n\n- **Accessibility** is a high-priority feature, and the interface works well\n  with assistive technology such as screen readers.\n\n- 100% committed to **open source**; you can see exactly what the code does and\n  make improvements, or \u003cstrong\u003eself-host\u003c/strong\u003e it for any purpose.\n\n- **Own your data**; you can always export all data and **cancel at any time**.\n\n- Integrate on your site with just a **single script tag**:\n\n      \u003cscript data-goatcounter=\"https://yoursite.goatcounter.com/count\"\n              async src=\"//gc.zgo.at/count.js\"\u003e\u003c/script\u003e\n\n- The JavaScript integration is a good option for most, but you can also use a\n  **no-JavaScript image-based tracker**, integrate it in your **backend\n  middleware**, or **parse log files**.\n\n[privacy]: https://www.goatcounter.com/privacy\n[gdpr]: https://www.goatcounter.com/gdpr\n[sessions]: http://www.goatcounter.com/help/sessions\n\n\nGetting data in to GoatCounter\n------------------------------\nThere are three ways:\n\n1. Add the JavaScript code on your site; this is the easiest and most common\n   method. Detailed documentation for this is available at\n   https://www.goatcounter.com/code\n\n2. Integrate in your middleware; send data to GoatCounter by calling the API\n   from your backend server middleware. Detailed documentation for this is\n   available at https://www.goatcounter.com/api#backend-integration\n\n3. Parse logfiles. GoatCounter can parse logfiles from nginx, Apache,\n   CloudFront, or any other HTTP middleware or proxy. See `goatcounter help\n   import` for detailed documentation on this.\n\n\nRunning your own\n----------------\n**Note this README is for the latest master and may be inaccurate for the latest\nreleased version; use the [`release-2.5`][latest] branch for the 2.5 README.**\n\nThe [release page][releases] has binaries for Linux amd64, arm, and arm64. These\nare statically compiled, contain everything you need, and should work in pretty\nmuch any Linux environment. The only other thing you need is somewhere to store\na SQLite database file or a PostgreSQL connection.\n\nGoatCounter should run on any platform supported by Go, but there are no\nbinaries for them (yet) as cross-compiling SQLite is somewhat complex. You'll\nhave to build from source if you want to run it on e.g. FreeBSD or macOS.\n\nGenerally speaking only the latest release is supported, although critical fixes\n(security, data loss, etc.) may get backported to previous releases.\n\n[releases]: https://github.com/arp242/goatcounter/releases\n[latest]: https://github.com/arp242/goatcounter/tree/release-2.5\n\n### Deploy scripts and such\n- [\"StackScript\" for Linode][stackscript]; Alpine Linux VPS; you can also use\n  this for other Alpine Linux machines.\n\n  If you don't have a Linode account yet then consider using my [referral\n  URL][linode] and I'll get some kickback from Linode :-)\n\n  [stackscript]: https://cloud.linode.com/stackscripts/659823\n  [linode]: https://www.linode.com/?r=7acaf75737436d859e785dd5c9abe1ae99b4387e\n\n- Some people have created Dockerfiles. You don't really need Docker since\n  GoatCounter has no external dependencies; it probably [creates more problems\n  than it solves][docker] IMHO. At any rate, here are some that seem alright at\n  a glance if you must:\n\n  - https://github.com/baethon/docker-goatcounter (https://hub.docker.com/r/baethon/goatcounter)\n  - https://github.com/sent-hil/dokku-gocounter\n  - https://github.com/anarcat/goatcounter/blob/Dockerfile/Dockerfile\n\n  [docker]: https://www.youtube.com/watch?v=PivpCKEiQOQ\n\n- Some other guides people have written:\n  - [Replacing Google Analytics with GoatCounter](https://rgth.co/blog/replacing-google-analytics-with-goatcounter/) (Ubuntu)\n  - [GoatCounter self-hosted setup on a VPS](https://actually.fyi/posts/goatcounter-vps/) (Arch Linux)\n  - [GoatCounter server setup on OpenBSD](https://daulton.ca/2021/01/openbsd-goatcounter-server/)\n\n\n### Building from source\nYou need Go 1.21 or newer and a C compiler (for SQLite). If you compile it with\n`CGO_ENABLED=0` you don't need a C compiler but can only use PostgreSQL.\n\nYou can install from source to $GOBIN (`go env GOBIN`) with:\n\n    % git clone --branch=release-2.5 https://github.com/arp242/goatcounter.git\n    % cd goatcounter\n    % go build -ldflags=\"-X zgo.at/goatcounter/v2.Version=$(git log -n1 --format='%h_%cI')\" ./cmd/goatcounter\n\nWhich will produce a `goatcounter` binary in the current directory.\n\nThe `-ldflags=[..]` sets the version; this isn't *strictly* required as such,\nbut it's recommended as it's used to \"bust\" the cache for static files and may\nalso be useful later when reporting bugs. This can be any string and doesn't\nfollow any particular format, you can also set this to the current date or\n`banana` or anything you want really.\n\nTo use the latest development version switch to the `master` branch.\n\nTo build a fully statically linked binary:\n\n    % go build -tags osusergo,netgo,sqlite_omit_load_extension \\\n        -ldflags=\"-X zgo.at/goatcounter/v2.Version=$(git log -n1 --format='%h_%cI') -extldflags=-static\" \\\n        ./cmd/goatcounter\n\nIt's recommended to use the latest release as in the above command. The master\nbranch should be reasonably stable but no guarantees, and sometimes I don't\nwrite detailed release/upgrade notes until the actual release so you may run in\nto surprises.\n\nYou can compile goatcounter without cgo if you're planning to use PostgreSQL and\ndon't use SQLite:\n\n    % CGO_ENABLED=0 go build \\\n        -ldflags=\"-X zgo.at/goatcounter.Version=$(git log -n1 --format='%h_%cI')\" \\\n        ./cmd/goatcounter\n\nFunctionally it doesn't matter too much, but builds will be a bit easier and\nfaster as it won't require a C compiler.\n\n### Running\nYou can start a server with:\n\n    % goatcounter serve\n\nThe default is to use an SQLite database at `./db/goatcounter.sqlite3`, which\nwill be created if it doesn't exist yet. See the `-db` flag and `goatcounter\nhelp db` to customize this.\n\nBoth SQLite and PostgreSQL are supported. SQLite should work well for most\nsmaller sites, but PostgreSQL gives better performance. There are [some\nbenchmarks over here][bench] to give some indication of what performance to\nexpect from SQLite and PostgreSQL.\n\nGoatCounter will listen on port `*:80` and `*:443` by default. You don't need\nto run it as root and can grant the appropriate permissions on Linux with:\n\n    % setcap 'cap_net_bind_service=+ep' goatcounter\n\nListening on a different port can be a bit tricky due to the ACME/Let's Encrypt\ncertificate generation; `goatcounter help listen` documents this in depth.\n\nYou can create new sites with the `db create site` command:\n\n    % goatcounter db create site -vhost stats.example.com -user.email me@example.com\n\nThis will ask for a password for your new account; you can also add a password\non the commandline with `-password`. You must also pass the `-db` flag here if\nyou use something other than the default.\n\n[bench]: https://github.com/arp242/goatcounter/blob/master/docs/benchmark.md\n\n### Updating\nYou may need to run the database migrations when updating. Use  `goatcounter\nserve -automigrate` to always run all pending migrations on startup. This is the\neasiest way, although arguably not the \"best\" way.\n\nUse `goatcounter db migrate \u003cfile\u003e` or `goatcounter db migrate all` to manually run\nmigrations; generally you want to upload the new version, run migrations while\nthe old one is still running, and then restart so the new version takes effect.\n\nUse `goatcounter db migrate pending` to get a list of pending migrations, or\n`goatcounter db migrate list` to show all migrations.\n\n### PostgreSQL\nTo use PostgreSQL run GoatCounter with a custom `-db` flag; for example:\n\n    % goatcounter serve -db 'postgresql+dbname=goatcounter'\n    % goatcounter serve -db 'postgresql+host=/run/postgresql dbname=goatcounter sslmode=disable'\n\nThis follows the format in the `psql` CLI; you can also use the `PG*`\n[environment variables](https://www.postgresql.org/docs/current/libpq-envars.html):\n\n    % PGDATABASE=goatcounter PGHOST=/run/postgresql goatcounter serve -db 'postgresql'\n\nThe database will be created automatically if possible; if you want to create it\nfor a specific user you can use:\n\n    % createuser --interactive --pwprompt goatcounter\n    % createdb --owner goatcounter goatcounter\n\nYou can manually import the schema with:\n\n    % goatcounter db schema-pgsql | psql --user=goatcounter --dbname=goatcounter\n\nSee `goatcounter help db` and the [pq docs][pq] for more details.\n\n[pq]: https://pkg.go.dev/github.com/lib/pq#hdr-Connection_String_Parameters\n\n### Development/testing\nYou can start a test/development server with:\n\n    % goatcounter serve -dev\n\nThe `-dev` flag makes some small things a bit more convenient for development;\nTLS is disabled by default, it will listen on localhost:8081, the application\nwill automatically restart on recompiles, templates and static files will be\nread directly from the filesystem, and a few other minor changes.\n\nSee [.github/CONTRIBUTING.md](/.github/CONTRIBUTING.md) for more details on how\nto run a development server, write patches, etc.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farp242%2Fgoatcounter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farp242%2Fgoatcounter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farp242%2Fgoatcounter/lists"}