Skip to content

livrasand/EthicalMetrics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

154 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

EthicalMetrics

Ask DeepWiki DOI Go Report Card Crowdin

EthicalMetrics was born from a simple frustration: every time we implemented Google Analytics, we felt like we were betraying our users' trust.

What if analytics could be both powerful AND ethical?

EthicalMetrics is our answer - a next-generation web analytics platform that delivers meaningful insights while protecting your users' privacy as a fundamental right, not an afterthought.

No cookies. No fingerprinting. No personal data. No compromises.

Important

EthicalMetrics is currently in beta. It is stable, but may still undergo breaking changes before v1.0. Recommended for technical users and privacy-focused teams.


Why EthicalMetrics?

  • True Anonymity by Design
    No IP collection. No device fingerprinting. No persistent IDs.
    100% anonymous, with no way to track individual users β€” by default.

  • Self-Hosted, Zero External Dependencies
    No third-party scripts, CDNs, or vendors. You own your data.

  • End-to-End Encryption
    Data is protected at rest using Redis. Built-in, not bolted on.

  • Core, Actionable Metrics
    Track visits, module usage, performance, events, and engagement β€” not people.

  • Lightweight & Easy to Use
    A single vanilla JS snippet. No frameworks. No bloat.
    Ethical by default β€” even without configuration.

  • Flexible Open API
    Send custom events and modules programmatically with minimal overhead.

  • Private Dashboards per Site
    Each site has its own dashboard secured with token-based access.

  • Portable by Nature
    Works on VPS, Docker, Render, or local environments. No lock-in.

EthicalMetrics exists to prove that analytics can be useful without being creepy.
πŸ‘‰ Read the Ethical Analytics Manifesto in FUNDAMENTALS.md

EthicalMetrics is growing fast β€” without compromising ethics.
πŸ‘‰ Check out the roadmap here

Why This Matters

In a world where 96% of websites track users without consent, EthicalMetrics represents a different path forward:

  • For Developers: Build with confidence knowing you're respecting user privacy
  • For Businesses: Gain insights without legal compliance headaches (GDPR, CCPA ready)
  • For Users: Browse freely without being surveilled and profiled
  • For the Web: Help create an internet that serves people, not advertisers

Join thousands of developers who are choosing ethics over surveillance capitalism.


Architecture Overview

Understanding how EthicalMetrics works internally helps you make the most of its privacy-first approach. The following diagrams illustrate the system's core components and data flow.

System Architecture

The complete EthicalMetrics system consists of four main layers working together:

flowchart TD
    %% Clusters/Groups
    subgraph Client_Layer
        Website["Website Integration"]
        ethicalmetrics_js["ethicalmetrics.js"]
    end

    subgraph Web_Interface
        nuevo_html["pricing.html"]
        dashboard_html["dashboard.html"]
        index_html["index.html"]
    end

    subgraph Server_Layer
        main_go["cmd/server/main.go"]
        handlers_go["internal/api/handlers.go"]
    end

    subgraph Data_Layer
        database_go["internal/db/database.go"]
        event_go["internal/models/event.go"]
        metrics_db["Redis"]
        sites_table["sites"]
        events_table["events"]
    end

    %% Connections
    Website --> ethicalmetrics_js
    ethicalmetrics_js -.-> handlers_go
    dashboard_html -.-> handlers_go
    index_html -.-> handlers_go

    main_go --> handlers_go
    main_go --> nuevo_html
    main_go --> dashboard_html
    main_go --> index_html

    handlers_go --> database_go
    handlers_go --> event_go

    database_go --> metrics_db
    metrics_db --> sites_table
    metrics_db --> events_table

    %% Style for dotted lines
    linkStyle 2,3,4 stroke:#999,stroke-dasharray:3
Loading

User Workflow

EthicalMetrics follows a simple three-stage process from registration to analytics:

flowchart TD
    %% Main Nodes
    START["Website Owner Starts"]
    REGISTER["Site Registration"]
    INTEGRATE["Client Integration"]
    ANALYTICS["View Analytics"]
    NUEVO_HANDLER["/nuevo API Endpoint"]
    TRACK_HANDLER["/track API Endpoint"]
    STATS_HANDLER["/stats API Endpoint"]
    REDIS_SITES["Redis Sites Storage"]
    REDIS_EVENTS["Redis Events Storage"]
    QUERY_DATA["Query aggregated data"]
    SITE_ID["site_id + admin_token"]
    EVENT_STORAGE["Anonymous Event Storage"]
    DASHBOARD_DATA["por_modulo + por_dia stats"]

    %% Connections
    START --> REGISTER
    REGISTER --> INTEGRATE
    REGISTER --> NUEVO_HANDLER
    INTEGRATE --> ANALYTICS
    INTEGRATE --> TRACK_HANDLER
    ANALYTICS --> STATS_HANDLER
    NUEVO_HANDLER --> REDIS_SITES
    TRACK_HANDLER --> REDIS_EVENTS
    STATS_HANDLER --> QUERY_DATA
    REDIS_SITES --> SITE_ID
    REDIS_EVENTS --> EVENT_STORAGE
    QUERY_DATA --> DASHBOARD_DATA

    %% Styling for better visualization
    classDef process fill:#e1f5fe,stroke:#039be5
    classDef storage fill:#e8f5e9,stroke:#43a047
    classDef endpoint fill:#fff3e0,stroke:#fb8c00
    classDef data fill:#f3e5f5,stroke:#8e24aa

    class START,REGISTER,INTEGRATE,ANALYTICS process
    class NUEVO_HANDLER,TRACK_HANDLER,STATS_HANDLER endpoint
    class REDIS_SITES,REDIS_EVENTS,QUERY_DATA storage
    class SITE_ID,EVENT_STORAGE,DASHBOARD_DATA data
Loading

API Endpoints

The system exposes three main API endpoints that handle all core functionality:

flowchart TD
    %% Clusters/Groups
    subgraph HTTP_Endpoints
        track_endpoint["/track"]
        nuevo_endpoint["/nuevo"]
        stats_endpoint["/stats"]
        static_endpoint["/static/*"]
    end

    subgraph Handler_Functions
        TrackHandler["TrackHandler"]
        NuevoHandler["NuevoHandler"]
        StatsHandler["StatsHandler"]
        StaticHandler["http.FileServer"]
    end

    subgraph Database_Operations
        InsertEvent["INSERT INTO events"]
        InsertSite["INSERT INTO sites"]
        SelectStats["SELECT aggregated data"]
    end

    subgraph Response_Data
        EventModel["models.Event"]
        SiteResponse["site_id + admin_token"]
        StatsResponse["por_modulo + por_dia"]
    end

    %% Connections
    track_endpoint --> TrackHandler
    nuevo_endpoint --> NuevoHandler
    stats_endpoint --> StatsHandler
    static_endpoint --> StaticHandler

    TrackHandler --> InsertEvent
    NuevoHandler --> InsertSite
    StatsHandler --> SelectStats

    InsertEvent --> EventModel
    InsertSite --> SiteResponse
    SelectStats --> StatsResponse

    %% Styling
    classDef endpoint fill:#e3f2fd,stroke:#1976d2
    classDef handler fill:#e8f5e9,stroke:#388e3c
    classDef db_operation fill:#fff3e0,stroke:#ffa000
    classDef response fill:#f3e5f5,stroke:#8e24aa

    class HTTP_Endpoints endpoint
    class Handler_Functions handler
    class Database_Operations db_operation
    class Response_Data response
Loading

Algorithms

Average session duration:

$$\bar{D} = \frac{1}{N} \sum _{i=1}^{N} d_i \quad \text{(where } d_i > 0\text{)}$$

Weekly comparison:

$$W_{\text{current}}[d] = \sum _{e \in E_{\text{current}}} \mathbb{I}(\text{day}(e) = d)$$

Retention per page:

$$R_p = \left| \{ \text{date}(e) \mid e \in E_p \} \right|$$

Token Generation

$$\text{Token} = \bigoplus _{i=1}^{24} \text{charset}[\lfloor 62 \cdot U(0,1) \rfloor]$$

πŸš€ Get Started in 60 Seconds

Step 1: Get Your Credentials

Visit ethicalmetrics.onrender.com and click "Create Account" - no email required!

Step 2: Add One Line of Code

<script src="https://ethicalmetrics.leapcell.app/ethicalmetrics.js?id=YOUR_SITE_ID"></script>

Step 3: View Your Analytics

Access your private dashboard instantly - that's it! πŸŽ‰

Want advanced features? Sponsor the project for early access to Professional analytics tools.

Ultra-simple banner customization:
You can easily customize the consent banner by adding data-* attributes to the script tag:

<script
  src="https://ethicalmetrics.leapcell.app/ethicalmetrics.js?id=YOUR_SITE_ID"
  data-banner-bg="#222"
  data-banner-color="#fff"
  data-banner-btn-bg="#4a90e2"
  data-banner-btn-color="#fff"
  data-banner-text="We respect your privacy. DNT is enabled. Only if you accept, we collect anonymous analytics."
  data-banner-btn-text="Accept"
></script>

Domain restriction banner customization:
If the tracker is used on a non-registered domain, it can show a warning banner. You can customize it using:

<script
  src="https://ethicalmetrics.leapcell.app/ethicalmetrics.js?id=YOUR_SITE_ID"
  data-domain-banner-text="This script can only be used on the registered domain."
  data-domain-banner-bg="#fff5f5"
  data-domain-banner-color="#7f1d1d"
  data-domain-banner-border="#fecaca"
></script>

Change colors and text as you wish β€” no coding required!

  1. Optionally, define a custom module for richer context:
<body data-modulo="home">
  ...
  <script src="https://ethicalmetrics.leapcell.app/ethicalmetrics.js?id=YOUR_SITE_ID"></script>
</body>
  1. Access your private dashboard:
https://ethicalmetrics.leapcell.app/dashboard.html?site=YOUR_SITE_ID&token=YOUR_ADMIN_TOKEN

Join the Movement

EthicalMetrics is more than software - it's a statement that privacy and analytics can coexist.

Ways to Contribute:

  • πŸ’° Sponsor the project - Fund development and get exclusive access
  • πŸ› Report issues - Help us improve
  • πŸ”§ Submit PRs - Code contributions welcome
  • 🌍 Help translate - Make it accessible worldwide. Some of these translations are done by AI, which may not be of the highest quality.
  • πŸ“’ Spread the word - Share with fellow privacy advocates

Every contribution helps build a more ethical web.

Made with πŸ’š by @livrasand.


πŸ›‘οΈ Ethical by design. Anonymous by default. Metrics with ethics. Do EthicalMetrics!

License

This project is available under a dual license model:

  • GNU GPL v3 for personal, educational, or compatible open source use.
  • EthicalMetrics Commercial License for commercial, SaaS, or proprietary products.

For a commercial license, see LICENSE-COMMERCIAL.md.

Cite this project

If you use EthicalMetrics in research or documentation, please cite it as follows:

Sandoval, L. (2025). livrasand/EthicalMetrics: v0.1.0-alpha (v0.1.0-alpha). Zenodo. https://doi.org/10.5281/zenodo.16121940

About

A privacy-focused, open-source web analytics platform designed as a powerful alternative to Google Analytics. Powered by an active community dedicated to ethical data tracking. Assisted-by Jules.

Topics

Resources

License

GPL-3.0, Unknown licenses found

Licenses found

GPL-3.0
LICENSE
Unknown
LICENSE-COMMERCIAL.md

Code of conduct

Stars

Watchers

Forks

Sponsor this project

  •  

Contributors