Vanilla JavaScript, HTML5 & Static Sites

Lightweight JavaScript analytics and telemetry beacon

Universal sub-3.2 KB asynchronous JavaScript tracker. Zero external dependencies, cookieless daily hashing, Core Web Vitals RUM, and automated crash capture.

Sub-3.2KB Brotli PayloadZero External DependenciesNon-Blocking Asynchronous LoadGlobal Window API Accessnavigator.sendBeacon TransportAutomated Error Triage
Quick Installation
<script defer src="https://api.openanalytics.org.in/open.js" data-project-id="YOUR_PROJECT_ID"></script>

Complete JavaScript Integration Guide

Follow these steps to track pageviews, custom events, Core Web Vitals, and errors.

1Embed Script Tag

Place the script tag in your document `<head>`. The `defer` attribute ensures non-blocking execution while preserving initial load paint performance.

index.html
<script
  defer
  src="https://api.openanalytics.org.in/open.js"
  data-project-id="prj_your_project_id"
></script>

2Configuration Data Attributes

Configure custom reporting endpoints or publishable API keys directly via script data attributes.

index.html
<script
  defer
  src="https://api.openanalytics.org.in/open.js"
  data-project-id="prj_your_project_id"
  data-endpoint="https://analytics.yourcompany.com"
  data-api-key="pk_live_optional_key"
></script>

3Global Window API Methods

Once initialized, Open Analytics exposes a clean global namespace on `window.OpenAnalytics`.

main.js
// Manual Pageview (for custom router implementations)
window.OpenAnalytics.page("/virtual-page-url");

// Custom Event Dispatch
window.OpenAnalytics.track("signup_modal_opened", { source: "header" });

// Manual Error Reporting
window.OpenAnalytics.captureError(new Error("Network timeout"), { retries: 3 });
Custom Events & Conversions

Attaching Custom Event Listeners

Track button clicks or form submissions using standard vanilla JavaScript event listeners.

document.getElementById("cta-button")?.addEventListener("click", () => {
  if (window.OpenAnalytics) {
    window.OpenAnalytics.track("demo_requested", {
      plan: "enterprise",
      page_scroll_depth: Math.round((window.scrollY / document.body.scrollHeight) * 100),
    });
  }
});
Core Web Vitals RUM

Automated Field Performance

The vanilla beacon listens to W3C PerformanceObserver entries for LCP, INP, CLS, FCP, and TTFB passively in the background, flushing metrics when the visitor hides the tab or completes a session.

Error Observability

Runtime Crash Triage

Attaches global listeners to `window.onerror` and `window.onunhandledrejection`, automatically packaging stack traces, script origins, and action breadcrumbs for edge ingestion.

Developer Questions

Frequently Asked Questions

Add Open Analytics to your JavaScript app today

Zero cookies, sub-3.2 KB payload, real-time Core Web Vitals RUM, and automated crash triage.