All docsSearch docs

Start

  1. 01Getting started
  2. 02Install
  3. 03Tracking

Features

  1. 04The dashboard
  2. 05Goals
  3. 06Short links
  4. 07AI sources and agents
  5. 08Email reports
  6. 09Scheduled check
  7. 10Ask your AI

Reference

  1. 11Performance
  2. 12Configuration
  3. 13HTTP API

Platforms

  1. 14Standalone server
  2. 15ClickHouse
  3. 16PHP
  4. 17WordPress
  5. 18Drupal
  6. 19Craft CMS
  7. 20Webflow
  8. 21Python
  9. 22Rails
  10. 23Ruby
  11. 24Go
  12. 25Java
  13. 26.NET
  14. 27Elixir
  15. 28Rust

Trust

  1. 29Privacy

Start

Tracking

The script counts some things on its own, and this page shows how to send your own events and change the settings on the script tag.

What it counts by itself

With just the script tag, Runlight records these on its own.

  • Pageviews, including page changes in single page apps (it follows history.pushState, replaceState when the path changes, and the back button).
  • Engaged time and scroll depth for each pageview. Time only counts while the tab is visible and focused.
  • Outbound links, recorded as an Outbound link event with the url when someone clicks a link to another site.
  • File downloads, recorded as a File download event with the url when someone clicks a link to a PDF, zip, disk image, document, audio, or video file. Both keep the url without its query string or fragment, as page paths are kept, since tokens and email addresses can ride in them.
  • 404s, on a page whose script tag has data-404 (see below). Each one is an event named 404 whose path property is the address that was not found, so the properties of 404 in the Events box list the broken addresses people reached and how often.

Runlight skips visits from known bots and from browsers driven by automation, such as Playwright, Selenium, and Puppeteer.

Your own events

Call runlight with a name, and optionally some properties.

js

runlight("Newsletter signup", { source: "footer" });
runlight("Purchase", { plan: "pro", revenue: 49 });

Properties can be strings, numbers, or booleans. Each event takes up to 30 of them, with names up to 60 characters and values up to 500. Events count toward visits and can be goals.

If your code may run before the script has loaded, queue the calls.

html

<script>
  window.runlight = window.runlight || function () { (window.runlight.q = window.runlight.q || []).push(arguments); };
</script>

Clicks with no JavaScript

Give any element a data-runlight attribute and a click on it sends that event. Extra data-runlight-* attributes become properties.

html

<button data-runlight="Signup" data-runlight-plan="pro">Sign up</button>

To count clicks on something you cannot edit, add a click goal in the dashboard, which needs no code at all.

Settings on the script tag

Attribute What it does
data-site="id" Which site, when one install serves several sites and hostnames are not enough.
data-hash Count changes to location.hash as pageviews (for hash routers).
data-404 Mark this page as a 404, so the pageview also records a 404 event with the page’s path. Put it on your not-found page, as the WordPress, Drupal, and Craft plugins do for you.
data-dnt Respect Do Not Track. It is off by default, since Runlight keeps nothing personal.
data-outbound="false" Do not record outbound link clicks.
data-downloads="false" Do not record file downloads.
data-exclude="/admin/*,/preview" Record nothing on these pages, neither pageviews nor events. Separate patterns with commas, and use * to match anything.
data-manual Send no pageviews automatically. Call runlight.pageview() when a page is shown, or runlight.pageview("/checkout/step-2") to name the page.
data-before-send="scrubAnalytics" Call a synchronous function on window before sending each payload. Return the scrubbed plain object, or null to send nothing. Define it before the tracker loads. A missing function, a thrown error, or a non-object result stops that payload. This applies to pageviews, events, and engagement updates. Scrub u (page URL), r (referrer), t (title), and any sensitive event properties in p. Async functions are not supported.

Leaving yourself out

In the dashboard, Settings, General has an Ignore this browser switch. If your dashboard is on a different domain from the site, open any page of the site with ?runlight=ignore in each browser you use. That browser stays out for a year from the last time it opened such a link, and ?runlight=track undoes it. The switch in the dashboard has no end.

This flag is the only thing the script ever stores, and it exists only in browsers where you chose to set it.