/observe

Simple traffic analytics collection for static websites.

Primary LanguageGoMIT LicenseMIT

observe

Simple traffic analytics collection for static websites. Observe is designed for a situation where:

  • You have a static web site
  • You don't control the site's server (say, GitHub Pages)
  • You don't want Google Analytics
  • But, you do want some form of metrics.

Observe is designed to be runnable in the free tier of Google Cloud; right now it only supports BigQuery as a storage backend, and is intended to be run under App Engine. It also has a standalone server which can be run anywhere.

Warning: This is alpha software; it's really only written for my use case. If your use case and mine are similar, it will might work for you!

Running

Create a BigQuery table with provided schema; observe cannot yet create its own:

# get the code
go get -u github.com/fardog/observe/cmd/observe
# create the schema
bq mk --table --description 'Observed visits' \
  --time_partitioning_field=Observed \
  --time_partitioning_expiration 7776000 \
  <gcloud_project_name>:observe.observations \
  $GOPATH/src/github.com/fardog/observe/bq-schema.json
# run the observer
observe -gcloud-project-id <gcloud_project_name> -bigquery-table observe.observations

You may run observe -help to view all options.

Usage

When running Observe exposes a single endpoint, which serve a 1x1 pixel transparent GIF image: /observe.gif. Whenver that image is loaded, an entry will be written to BigQuery with the following:

  • The URL visited (taken from the Referrer headers)
  • The anonymized IP address of the viewer (IPv4 to 20 bits, IPv6 to 32 bits)
  • The time observed
  • A list of all header values the browser sent

You may also manually specify the URL visited, if you don't want to rely on the referrer headers: /observe.gif?referrer=https://cool.site/awesome-page/

Observe respects the Do Not Track header, and will serve the gif to the requester but not log or store their information. There is no option to disable this behavior.

Running on App Engine

Observe was designed to run on Google Cloud App Engine, or as a standalone server. Running on App Engine should involve only a gcloud app deploy from within the cmd/observe-appengine directory with a properly configured Google Cloud SDK.

TODO

  • Attempt to create schema if not present
  • Tests

License

MIT