📊🌍 Super small, light, privacy-focused, self-hostable web statistics provider

Overview

femtostats

Update: It turns out Fathom Lite does everything I wanted to do except custom events for free, so I'm going to stop working on this for now.

Femtostats is a super lightweight, tiny, privacy-focused web statistics provider.

build status

CleanShot 2022-09-20 at 19 05 11@2x

Why?

I needed:

  • A simple way to track visits on various web properties I manage
  • A way to collect statistics without using the privacy-invasive Google Analytics, which half of my visitors probably block
  • The ability to track custom events triggered from JavaScript, as well as other client-side stats like screen size
  • Realtime visitor count when there are surges
  • A container that I can add to docker-compose.yml or host on Fly.io trivially
  • No database dependencies because my main host is low on RAM

Why not use your web server's log files and something like GoAccess? A good idea, but I want client-side information and custom events.

Why not Plausible? Plausible is awesome but requires installing both Postgres and Clickhouse. I'm short on RAM.

Why not an AWS CloudFront load balancer that hosts a single pixel and sends logs to an S3 bucket which you can query using Athena? This is an awesome scaleable and cheap solution, but the CloudFront logs are only dumped once per day, which is too infrequent for me.

Getting Started

  1. Host the image ghcr.io/statico/femtostats wherever you want. Check out the docker-compose.yml file in this repo as an example. Specify a PASSWORD env var to protect your dashboard behind a password (the username is admin).
  2. Include the tag <script defer src="https://your-femtostats.com/fs.js"></script> on the pages you want to track.
  3. Page views (including history changes on SPAs) are tracked automatically. For custom events, call window.femtostats('event name')

Enabling Country Resolution

To record which country the user has originated from, you need a geoip database. Femtostats will automatically download a free one from Maxmind and refresh it once a week if you do the following:

  1. Go to https://www.maxmind.com/ and register for a free account
  2. Under "Manage License Keys", get a license key
  3. Under "Download Files", scroll to the "GeoLite2 Country" row and click "Get Permalinks". Get the database URL (it will look like https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=YOUR_LICENSE_KEY&suffix=tar.gz) and replace YOUR_LICENSE_KEY with your license key.
  4. Set this URL as an environment variable MAXMIND_GEOLITE2_COUNTRY_URL

Disabling Cookies

By default, Femtostats stores a simple cookie on the client to keep track of user sessions. You can disable the use of cookies entirely by setting the env var NO_COOKIES=1. Sessions will still show in the dashboard, but without cookies, the definition of a session changes from "a user's browser session" to "a single page view."

Development

Requires Node.js 16+ and Yarn. Run yarn and yarn dev.

The default database location is /tmp/stats.db. Run yarn exec knex seed:run to populate the database with some sample data.

This project uses Next.js, React, SWR, Recoil, Chakra UI, and Chart.js.

Future Ideas

  • Realtime visitor count
  • Visitors vs. pageviews
  • Track country codes with the MaxMind database
  • Do some load testing
  • Use the better-sqlite3 driver
  • Support other databases, maybe, I dunno
You might also like...

Mercure Provider - Real-time Made Easy

Mercure Provider - Real-time Made Easy

@setten/mercure is a Mercure client for AdonisJS. Mercure allows you to use Server Sent Events to push data to your clients using Http. Note You must

Nov 29, 2022

simple statistics for node & browser javascript

Simple Statistics A JavaScript implementation of descriptive, regression, and inference statistics. Implemented in literate JavaScript with no depende

Jan 7, 2023

Statistics toolkit for JavaScript

statkit A statistics toolkit for javascript. Usage Install using npm: npm install statkit Fit a linear regression model using MCMC: var sk = require(

Dec 19, 2022

A tool to get plugin statistics of Obsidian plugin ecosystem.

A tool to get plugin statistics of Obsidian plugin ecosystem.

Obsidian Plugin Stats A tool to get plugin statistics of Obsidian plugin ecosystem. Usage You can use this tool to see the plugins that has hit commun

Dec 25, 2022

My personal profile with dynamic github statistics, coding infos, music status with the spotify API.

Oh, Hello there 👋 My name's Mouhcine, A recent bachelor Graduate Security Researcher/Student from 🇲🇦 . Currently Working on other projects. 📬 Soci

Oct 29, 2022

An app to test out your typing speed, save your progress and view statistics against them.

An app to test out your typing speed, save your progress and view statistics against them.

Introduction An app to test out your typing speed, save your progress and view statistics against them. Demo Check out the quick demo here. Getting St

Sep 7, 2022

Statistics plugin for RemNote that will give you some helpful numbers, charts and heatmap for your knowledge base.

RemNote statistics plugin Features This plugin will give you the following statistics: Retention rate Number of cards due in future Type of buttons yo

Sep 9, 2022

A small javascript DOM manipulation library based on Jquery's syntax. Acts as a small utility library with the most common functions.

Quantdom JS Quantdom is a very small (about 600 bytes when ran through terser & gzipped) dom danipulation library that uuses a Jquery like syntax and

Aug 16, 2022

✏️ A small jQuery extension to turn a static HTML table into an editable one. For quickly populating a small table with JSON data, letting the user modify it with validation, and then getting JSON data back out.

jquery-editable-table A small jQuery extension to turn an HTML table editable for fast data entry and validation Demo 👉 https://jsfiddle.net/torrobin

Jul 31, 2022
Owner
Ian Langworth ☠
🐁➡➡⬇⬇⬇⬆⬅⬇⬇⬇ ➡➡⬇➡⬅➡⬇⬅⬆⬆⬇ ⬇⬅⬇⬇⬇⬆➡⬅➡➡⬇ ⬅➡➡⬇⬇➡⬆➡⬆⬇⬇ ➡⬆⬇⬅⬅⬅⬆⬅⬇⬅⬆ ⬅⬆⬇➡➡➡⬆⬅➡➡🧀
Ian Langworth ☠
⚡ Self-hostable branded link shortener built with Next.js & Notion API

Notiolink ⚡ Self-hostable branded link shortener built with Next.js & Notion API Made by Theodorus Clarence Installation Guide Please read the full gu

Theodorus Clarence 144 Dec 27, 2022
😂 is a self-hostable blog engine built on the tech that powers christine.website

?? ?? is a blog engine powered by Deno. ?? has no canonical pronunciation, and users are not encouraged to come up with one. ?? is and always will be

Xe Iaso 25 Sep 4, 2022
Privacy Pass: a privacy-enhancing protocol and browser extension.

Privacy Pass Extension The Privacy Pass protocol is now being standardised by the privacypass IETF working group. All contributions are welcome! See t

Privacy Pass Team 1.1k Jan 7, 2023
Privacy-focused Google Fonts alternative

Privacy-focused Google Fonts CDN alternative I wrote it in an hour, so please report bugs here. Several improvements could be made here and there, so

coolLabs 245 Dec 27, 2022
🌗 1 line of code to apply auto dark / light theme and support custom theme for your website. Super fast and lightweight theme library.

themes.js A super lightweight and fast Theme library with auto system color scheme detection in JavaScript. Features Auto detect Dark / Light mode by

SerKo 4 Nov 29, 2022
Use Matrix as a backend for local-first applications with the Matrix-CRDT Yjs provider.

Matrix CRDT Matrix-CRDT enables you to use Matrix as a backend for distributed, real-time collaborative web applications that sync automatically. The

Yousef 604 Jan 7, 2023
Web3.js provider to interact with the VeChain Thor protocol

web3-providers-connex Web3.js provider implemented using Connex.js. It makes it possible to use web3.js and ethers.js to interact with VeChain Thor pr

null 13 Dec 26, 2022
🌱 Ethereum provider solution for Dapp&Wallets, 🏷 If you have good suggestions, please submit issues

English | 简体中文 | 日本 ETH Wallet Modal An Ethereum Provider Solution for Integrated Wallets and Dapps ⚠️ Notice If you need to reduce unnecessary import

Dan Xu 35 Dec 19, 2022
☁️ Application using Node.js, AdonisJs, Adonis ACL, Adonis Kue Provider, Adonis Mail, Adonis Lucid Slugify, Adonis Validator, AdonisJs Redis, ESLint and pg

Node.js - SaaS ☁️ Application using Node.js, AdonisJs, Adonis ACL, Adonis Kue Provider, Adonis Mail, Adonis Lucid Slugify, Adonis Validator, AdonisJs

null 4 Aug 19, 2022
Cross provider map drawing library, supporting Mapbox, Google Maps and Leaflet out the box

Terra Draw Frictionless map drawing across mapping providers. TerraDraw centralises map drawing logic and provides a host of out the box drawing modes

James Milner 106 Dec 31, 2022