OpenBento can track:
- Inbound traffic: page views on the exported bento page
- Outbound traffic: clicks on blocks (links / social)
This is done via two Supabase Edge Functions:
openbento-analytics-track(public write endpoint - handles auth securely server-side)openbento-analytics-admin(admin read endpoint, protected by a token)
No API keys are exposed in the exported code!
The analytics system uses Supabase Edge Functions which handle authentication server-side with the SERVICE_ROLE_KEY. The client only needs the Supabase project URL - no anonKey is required or exposed.
- Create a Supabase project
- Install the Supabase CLI: https://supabase.com/docs/guides/cli
- Get:
SUPABASE_PROJECT_REF(project ref)SUPABASE_SERVICE_ROLE_KEY(Settings → API → Service role key)- Pick an
OPENBENTO_ANALYTICS_ADMIN_TOKEN(any strong random string)
From the repo root:
SUPABASE_PROJECT_REF=xxxx \
SUPABASE_SERVICE_ROLE_KEY=... \
OPENBENTO_ANALYTICS_ADMIN_TOKEN=... \
npm run analytics:supabase:initThis will:
- Apply the migration in
supabase/migrations/ - Set Edge Function secrets
- Deploy the Edge Functions
In the Builder sidebar:
- Go to Analytics (Supabase)
- Toggle Enable analytics
- Paste your Supabase Project URL (example:
https://xxxx.supabase.co)
Note: The
anonKeyfield is deprecated and no longer required. Only the project URL is needed.
When you export, the generated page will automatically send page_view and click events via the Edge Function.
In the builder, open Analytics and paste your OPENBENTO_ANALYTICS_ADMIN_TOKEN.
The dashboard calls:
{SUPABASE_URL}/functions/v1/openbento-analytics-admin?siteId=...