Web analytics
Add the web analytics tracker
Count visitors without cookies, track custom events with properties and see which signed-in users come back, with one script tag.
The Logdash tracker counts visitors, pageviews and sessions, where visitors come from and what they browse with, without cookies. Track the actions that matter as custom events, break them down by properties, and identify signed-in users to see who comes back.
Add the script
- Start tracking In Logdash, open your domain, go to Analytics, enter your website address and press Start tracking.
- Paste the snippet Paste the snippet it shows into the
<head>of every page. The site ID in it is public and safe to ship in your HTML.index.html<script defer src="https://logdash.io/sdk/web.js" data-site="your-site-id" data-endpoint="https://api.logdash.io/web_events" ></script> - Open your site Load any page of your site, then go back to Analytics in Logdash. The dashboard opens on today, live, so your visit is there.
Ad blockers often block analytics served from another domain. To count those visitors too, serve the tracker from your own domain.
What the tracker sends
| Event | When |
|---|---|
pageview | On load, and whenever the path changes through pushState, replaceState, back and forward, or a page restored from the back-forward cache. Single-page apps need no extra code. |
pageleave | When the visitor leaves the page or hides it, such as by switching tabs or apps, for session time and exit pages. |
interaction | On the first click, tap or typed key on each page. Scrolling and browser shortcuts do not count. A visit with an interaction is not a bounce. |
browser_error | For uncaught errors and unhandled promise rejections, without the error message or stack trace. |
| Custom events | When you call track, described in Custom events. |
Events are sent in small batches about a second after they happen, and right away when the page is hidden.
The JavaScript API
The tracker exposes its API as window.logdash. Call it with ?., because the object does not exist before the deferred script has loaded or in browsers where the tracker does not start.
| Method | What it does |
|---|---|
track(name, properties?) | Sends a custom event. |
identify(id) | Links later events to a signed-in user. identify(null) clears it. |
optOut() | Stops tracking in this browser until optIn(). See Opt-out. |
optIn() | Starts tracking again after optOut(). |
window.logdash?.track('signup_completed', { plan: 'pro' }); Script attributes
| Attribute | Description |
|---|---|
data-site | Your site ID, from the snippet in Logdash. Required. |
data-endpoint | Where events go: https://api.logdash.io/web_events, or /_ld/events behind your own proxy. |
data-respect-dnt | Keeps the tracker from starting in browsers that send Do Not Track or Global Privacy Control. |
Plan limits
Your plan sets how long events are kept, counted from the time of each event, and how many events each domain takes per hour. Past that, the events endpoint answers 429 until the next full hour in UTC.
| Limit | Hobby | Builder | Pro |
|---|---|---|---|
| Retention | 90 days | 180 days | 365 days |
| Events per domain per hour | 10,000 | 25,000 | 50,000 |
Privacy
The tracker sets no cookies, IP addresses are never stored, and anonymous visitors are counted with an ID that changes every day. Web analytics and privacy describes what Logdash stores and for how long, and gives you text for your privacy policy.