Developer Documentation

Pirsch Analytics Integration

Privacy-friendly, server-side analytics for all Reformer clients

Partially Working

Status: Tracking works on reformer.la. API read access for stats needs configuration. Currently shows "Open Pirsch" button in dashboard (acceptable).

Quick Setup (5 Minutes)

1. Create Pirsch Dashboard

  1. Go to https://pirsch.io
  2. Click Add Dashboard
  3. Enter client's domain (e.g., clientname.com)
  4. SettingsIntegrationAdd Client
  5. Select Access Key
  6. Copy the key (starts with pa_...)

2. Add to Database

Run this SQL in pgAdmin (Render database):

INSERT INTO integrations (account_id, service, api_key, config, active)
SELECT id, 'pirsch', 'pa_ACCESS_KEY_HERE',
  jsonb_build_object('type', 'access_key', 'domain', 'clientdomain.com', 'autoTrack', true),
  true
FROM accounts WHERE dashboard_slug = 'client-slug'
ON CONFLICT (account_id, service) 
DO UPDATE SET 
  api_key = EXCLUDED.api_key, 
  config = EXCLUDED.config;

3. Test It

curl https://reformer-platform.onrender.com/api/analytics/ACCOUNT_UUID/test

Should return: {"configured": true, ...}

4. Add Tracking to Website

Webflow custom code (Before </body>):

<script>
fetch('https://reformer-platform.onrender.com/api/analytics/ACCOUNT_UUID/track', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    url: window.location.href,
    userAgent: navigator.userAgent,
    headers: {
      referer: document.referrer,
      acceptLanguage: navigator.language
    }
  })
});
</script>

API Endpoints

Method Endpoint Purpose
POST /api/analytics/:id/track Track page view
POST /api/analytics/:id/event Track custom event
GET /api/analytics/:id/stats Get statistics (needs permissions)
GET /api/analytics/:id/test Test integration
GET /api/analytics/accounts List all configured accounts

Common SQL Queries

Find Account UUID

SELECT id, business_name FROM accounts WHERE dashboard_slug = 'client-slug';

Check Pirsch Status

SELECT a.business_name, i.api_key, i.config, i.active
FROM integrations i
JOIN accounts a ON i.account_id = a.id
WHERE i.service = 'pirsch';

List Accounts Without Analytics

SELECT a.business_name, a.dashboard_slug
FROM accounts a
LEFT JOIN integrations i ON i.account_id = a.id AND i.service = 'pirsch'
WHERE i.id IS NULL;

Update Access Key

UPDATE integrations 
SET api_key = 'pa_NEW_KEY'
WHERE account_id = 'UUID' AND service = 'pirsch';

Pricing

Plan Cost/month Page Views Best For
Starter $10 10k 1-3 small clients
Growth $19 100k 5-10 clients
Business $49 1M Unlimited clients

URL: https://pirsch.io/pricing

Troubleshooting

Error Solution
"Pirsch not configured" Run setup SQL, check api_key exists
"401 Unauthorized" Access key invalid, regenerate in Pirsch
No data in dashboard Check tracking code, wait 5 minutes
API read access fails Access key may lack read permissions - acceptable, use "Open Pirsch" button

Resources