Giter Club home page Giter Club logo

goatcounter's Introduction

Build Status codecov

GoatCounter is a web analytics platform, roughly similar to Google Analytics or Matomo. It aims to give meaningful privacy-friendly web analytics for business purposes, while still staying usable for non-technical users to use on personal websites. The choices that currently exist are between freely hosted but with problematic privacy (e.g. Google Analytics), hosting your own complex software or paying $19/month (e.g. Matomo), or extremely simplistic "vanity statistics".

There are two ways to run this: as hosted service on goatcounter.com, free for non-commercial use, or run it on your own server.

See docs/rationale.markdown for some more details on the "why?" of this project.

There's a live demo at https://stats.arp242.net.

Please consider donating if you're self-hosting GoatCounter so I can pay my rent :-)

Features

  • Privacy-aware; doesn't track users with unique identifiers and doesn't need a GDPR consent notice. Also see the privacy policy.

  • Lightweight and fast; adds just 3.5K (1.9K compressed) of extra data to your site.

  • Easy; if you've been confused by the myriad of options and flexibility of Google Analytics and Matomo that you don't need then GoatCounter will be a breath of fresh air.

  • Accessibility is a high-priority feature, and the interface works well with screen readers, no JavaScript, and even text browsers (although not all features work equally well without JS).

  • 100% committed to open source; you can see exactly what the code does and make improvements.

  • Own your data; you can always export all data and cancel at any time.

Technical

  • Fast: can handle about 800 hits/second on a $5/month Linode VPS using the default settings.

  • Self-contained binary: everything โ€“ including static assets โ€“ is in a single ~7M statically compiled binary. The only other thing you need is a SQLite database file or PostgreSQL connection (no way around that).

Running your own

There are binaries on the releases page, or compile from source with go get zgo.at/goatcounter/cmd/goatcounter, which will put the binary at ~/go/bin/goatcounter.

Go 1.12 and newer are supported (it follows the Go release policy). You will need a C compiler (for SQLite) or PostgreSQL.

Production

  1. For a production environment run something like:

    goatcounter \
        -prod \
        -smtp         'smtp://localhost:25' \
        -plan         'pro' \
        -domain       'example.com' \
        -domainstatic 'static.example.com' \
        -emailerrors  '[email protected]' \
        "$@"
    

    The default is to use a SQLite database at ./db/goatcounter.sqlite3 (will be created if it doesn't exist). See the -dbconnect flag to customize this.

    The -prod flag affects various minor things; without it it'll try to load templates from the filesystem (instead of using the built-in ones), for example.

    -smtp is required to send login emails. You can use something like Mailtrap if you just want it for yourself, but you can also use your Gmail or whatnot.

  2. Use a proxy for https (e.g. hitch or caddy); you'll need to forward example.com and *.example.com

You can see the goathost repo for the server configuration of goatcounter.com, although that is just one way of running it.

Updating

You may need to run run database migrations when updating. Use goatcounter -migrate auto to always run all pending migrations on startup. This is the easiest way, although arguably not the "best" way.

Use goatcounter -migrate <file> or goatcounter -migrate all to manually run migrations; generally you want to upload the new version, run migrations while the old one is still running, and then restart so the new version takes effect.

PostgreSQL

Both SQLite and PostgreSQL are supported. SQLite should work well for the vast majority of people and is the recommended database engine. PostgreSQL will not be faster in most cases, and the chief reason for adding support in the first place is to support load balancing web requests over multiple servers. To use it:

  1. Create the database, unlike SQLite it's not done automatically:

    $ createdb goatcounter
    $ psql goatcounter -c '\i db/schema.pgsql'
    
  2. Run with -pgsql and -dbconnect, for example:

    $ goatcounter -pgsql -dbconnect 'user=goatcounter dbname=goatcounter sslmode=disable'
    

    See the pq docs for more details on the connection string.

  3. You can compile goatcounter without cgo if you don't use SQLite:

    $ CGO_ENABLED=0 go build
    

    Functionally it doesn't matter too much, but you won't need a C compiler, builds will be faster, and makes creating static binaries easier.

Development

See .github/CONTRIBUTING.markdown for details on how to run a development server, write patches, etc.

goatcounter's People

Contributors

arp242 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.