Devlune
webmaster

Documentation

Everything you need to integrate Devlune Webmaster into your site.

Getting Started

Add your site in the dashboard, then drop a single script tag on your page. That's it.

  1. Go to Dashboard → Add Site
  2. Copy the tracking script
  3. Paste it before </head> on your site
  4. Visit your site — data appears in seconds

Analytics Script

Privacy-first, cookieless analytics. Under 2KB gzipped.

HTML
<script defer src="https://devlune-webmaster-edge.sidharth-6f3.workers.dev/embed/analytics.js" data-site="YOUR_SITE_ID"></script>

Replace YOUR_SITE_ID with your site ID from the dashboard.

Next.js

app/layout.tsx
import Script from 'next/script';

export default function Layout({ children }) {
  return (
    <html>
      <head>
        <Script src="https://devlune-webmaster-edge.sidharth-6f3.workers.dev/embed/analytics.js" data-site="YOUR_SITE_ID" strategy="afterInteractive" />
      </head>
      <body>{children}</body>
    </html>
  );
}

WordPress

functions.php
function devlune_analytics() {
  echo '<script defer src="https://devlune-webmaster-edge.sidharth-6f3.workers.dev/embed/analytics.js" data-site="YOUR_SITE_ID"></script>';
}
add_action('wp_head', 'devlune_analytics');

Custom Events

JavaScript
// Track a custom event
devlune.track('button_click', { button: 'signup', page: '/pricing' });

View Counter

Beautiful, customizable counters. Create one in the dashboard, then embed it.

Script embed (interactive widget)

HTML
<script defer src="https://devlune-webmaster-edge.sidharth-6f3.workers.dev/embed/view-counter.js" data-id="YOUR_COUNTER_ID"></script>

Badge embed (for READMEs, emails)

Markdown
![Views](https://devlune-webmaster-edge.sidharth-6f3.workers.dev/badge/YOUR_SITE_ID/page-path)
HTML
<img src="https://devlune-webmaster-edge.sidharth-6f3.workers.dev/badge/YOUR_SITE_ID/page-path" alt="Views" />

JSON API

curl
curl "https://devlune-webmaster-edge.sidharth-6f3.workers.dev/badge/YOUR_SITE_ID/page-path?format=json"
# → {"siteId":"...","page":"/...","count":1234,"mode":"total"}

Custom Forms

Embed forms with full CSS control via Shadow DOM isolation.

Script embed

HTML
<script defer src="https://devlune-webmaster-edge.sidharth-6f3.workers.dev/embed/forms.js" data-form="YOUR_FORM_ID"></script>
<div id="devlune-form"></div>

Headless mode (POST directly)

JavaScript
// 1. Get a token
const { token } = await fetch('https://devlune-webmaster-edge.sidharth-6f3.workers.dev/embed/token', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ formId: 'YOUR_FORM_ID' }),
}).then(r => r.json());

// 2. Submit
await fetch('https://devlune-webmaster-edge.sidharth-6f3.workers.dev/ingest/form', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${token}`,
  },
  body: JSON.stringify({
    name: 'John',
    email: 'john@example.com',
    message: 'Hello!',
  }),
});

Spam protection

Forms are protected by Cloudflare Turnstile (invisible) + rate limiting (5 submissions/min per IP). No CAPTCHAs shown to users.

API Reference

All endpoints require authentication via session cookie (dashboard) or service role key (server-to-server).

MethodEndpointDescription
GET/api/sitesList all sites
POST/api/sitesCreate a site
GET/api/formsList all forms
POST/api/formsCreate a form
GET/api/countersList all counters
POST/api/countersCreate a counter
POST/api/billing/checkoutCreate Stripe checkout session

Worker Endpoints (Public)

MethodEndpointDescription
POST/ingest/analyticsPageview/event ingest
POST/ingest/formForm submission
GET/badge/:siteId/:pageView counter badge (SVG/JSON/HTML)
POST/embed/tokenMint form embed token
GET/embed/*.jsEmbed scripts (from R2)