// context projectglobal

Web Analytics

A single <script> tag adds pageviews, custom events, auto-events, identity tracking, and Core Web Vitals to your site. Built on the same SDK that already ships logs from your browser — same API key, same endpoint, same dashboard.

Quick start (90 seconds)

Paste this into the <head> of every page you want to track:

<script
  src="https://app.logu.ro/loguro.js"
  data-api-key="brk_xxxxxxxxxxxx"
  data-analytics="all"
></script>

That’s it. You now get:

  • Initial pageview on every page load
  • SPA route changes auto-tracked (history.pushState / popstate)
  • Custom events via window.Loguro.track('signup_completed', { plan: 'pro' })
  • Auto-events on any element marked [data-loguro-event="..."]
  • Visitor + session IDs persisted in localStorage
  • Core Web Vitals (LCP, CLS, INP) reported automatically
  • Errors + failed network requests if you’ve already been using Loguro for logs

The default data-analytics="all" enables everything. To opt into specific features only, pass a comma-separated list — see Install & Configure.

What gets sent

All events POST to https://ingest.logu.ro/batch in batches of 20 or every 5 seconds (whichever comes first). On pagehide / visibilitychange:hidden the buffer flushes via navigator.sendBeacon so nothing is lost when the user closes the tab.

The wire shape (one envelope, multiple events):

{
  "type": "web_event",
  "events": [
    {
      "event_type": "pageview",
      "url": "https://example.com/pricing",
      "path": "/pricing",
      "visitor_id": "01HZ7XK4N8...",
      "session_id": "01HZ7XK4P2...",
      "timestamp": "2026-05-14T10:00:00.000Z",
      "custom_props": { "viewport": "1920x1080", "title": "Pricing | Acme" }
    },
    {
      "event_type": "custom",
      "custom_event_name": "signup_completed",
      "user_id": "user_42",
      "custom_props": { "plan": "pro" },
      "timestamp": "2026-05-14T10:00:02.000Z"
    }
  ]
}

Your IP address and User-Agent are read server-side from request headers and used for geo + browser/OS lookup. The SDK does not include them in the payload body.

Backwards compatible

If you’ve already had loguro.js on your site for logs, removing data-analytics (or leaving it absent) keeps behavior identical to before — only logs are sent. Adding analytics never breaks existing logging.

Next steps

// related

See also