Analytics setup guide

Analytics setup guide

Learn how to integrate Google Analytics 4 and Umami Analytics with EasyAPI

Overview

EasyAPI integrates with popular analytics platforms to help you track user behavior and site performance:

  • Google Analytics 4 (GA4): The latest version of Google's analytics platform, suited to full user behavior analysis and conversion tracking.
  • Umami Analytics: A privacy-focused, open-source analytics tool with lightweight deployment and cookie-free tracking, suited to self-hosted or compliance-sensitive environments.

You can enable both analytics tools at the same time without conflicts.

Features

  • Zero-code integration: configured entirely through environment variables
  • Scripts are injected into the web UI automatically
  • Works with Docker Compose and standalone deployments
  • Privacy-conscious implementation
  • No frontend code changes required

Google Analytics 4 setup

1. Get your measurement ID

  1. Go to Google Analytics
  2. Create a new property or select an existing one
  3. Open Admin → Data streams
  4. Create or select a web data stream
  5. Copy your Measurement ID (format: G-XXXXXXXXXX)

2. Configure environment variables

Docker Compose: edit docker-compose.yml and add the following under environment:

environment:
  - GOOGLE_ANALYTICS_ID=G-XXXXXXXXXX  # Replace with your actual measurement ID

Standalone deployment: add it to your .env file or set it as an environment variable:

export GOOGLE_ANALYTICS_ID=G-XXXXXXXXXX

Docker Run:

docker run -d \
  -e GOOGLE_ANALYTICS_ID=G-XXXXXXXXXX \
  ...other options... \
  easyapi/easyapi:latest

3. Restart the application

# Docker Compose
docker-compose down && docker-compose up -d

# Standalone deployment
# Restart your EasyAPI application

Umami Analytics setup

1. Get your Umami credentials

Option A: Umami Cloud

  1. Sign up for Umami Cloud
  2. Add a new website
  3. Copy your Website ID (UUID format)

Option B: Self-hosted Umami

  1. Deploy your own Umami instance
  2. Create a website in the dashboard
  3. Copy your Website ID and Script URL

2. Configure environment variables

Docker Compose:

environment:
  - UMAMI_WEBSITE_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
  # Optional: only required for self-hosted instances
  - UMAMI_SCRIPT_URL=https://your-umami-domain.com/script.js

Standalone deployment:

export UMAMI_WEBSITE_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
export UMAMI_SCRIPT_URL=https://your-umami-domain.com/script.js  # Optional

Note: If you use Umami Cloud, you don't need to set UMAMI_SCRIPT_URL; the official script URL is used by default.

3. Restart the application

Same as Google Analytics: restart EasyAPI to apply the changes.

Using both analytics tools

You can enable Google Analytics and Umami at the same time:

environment:
  - GOOGLE_ANALYTICS_ID=G-ABC123XYZ
  - UMAMI_WEBSITE_ID=a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6
  - UMAMI_SCRIPT_URL=https://analytics.umami.is/script.js

Verification

After restarting, open your browser's developer tools (F12) → Network and look for these requests:

  • Google Analytics: https://www.googletagmanager.com/gtag/js
  • Umami: the script URL you configured

You can also view the page source and look for the injected scripts in the <head> section.

Troubleshooting

Analytics not working?

  • Verify that the environment variables are set correctly
  • Restart the application after changing variables
  • Check the browser console for errors
  • Make sure the measurement ID or website ID format is correct
  • Check whether an ad blocker is interfering

Docker users:

docker exec <container-name> env | grep -E "GOOGLE_ANALYTICS|UMAMI"

Privacy considerations

  • Google Analytics collects user data under Google's privacy policy
  • Umami is privacy-focused and does not collect personal data
  • If you use analytics, consider adding a privacy policy to your site
  • Both tools are GDPR-compliant when configured correctly

Environment variable reference

VariableRequiredDefaultDescription
GOOGLE_ANALYTICS_IDNo-Google Analytics 4 measurement ID (format: G-XXXXXXXXXX)
UMAMI_WEBSITE_IDNo-Umami website ID (UUID format)
UMAMI_SCRIPT_URLNohttps://analytics.umami.is/script.jsUmami script URL (customize for self-hosted instances)