Install the script
One script tag of about 1 KB counts page views, custom events, and Web Vitals. Paste it once, and we confirm the first page view within seconds.
Before you start
You need a site in Lyli. Add its domain and reporting time zone at app.lyli.io/sites/new. Each site gets an ID that starts with s_, and its tag, with the ID filled in, is in Settings › Install.
Add the tag
Paste this before </head> on every page, or once in your app’s root layout. It runs after the page is parsed and doesn’t block rendering. Route changes in single-page apps are tracked automatically.
<script defer src="https://app.lyli.io/t.js" data-site="s_k3m9x2p7qa"></script>// app/layout.tsx
import Script from "next/script";
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
{children}
<Script
src="https://app.lyli.io/t.js"
data-site="s_k3m9x2p7qa"
strategy="afterInteractive"
/>
</body>
</html>
);
}// After the signup request succeeds
window.track?.("signup_completed", { plan: "team" });
// A payment: its amount as revenue, and its currency when it isn't the site's
window.track?.("purchase", { plan: "team", revenue: 49.9, currency: "USD" });
// Page views, including client-side route changes, are sent automatically.Strict content blockers stop requests to analytics hosts, so those visitors go uncounted. With Via your domain, your server serves the script and forwards each page view to us with the visitor’s IP address, so they’re counted and placed in the right city. We never store IP addresses in our database.
Forward two paths on your domain: /k3m9x2p7qa/script.js and /k3m9x2p7qa/event, unique to your site. Nothing else is forwarded.
Add the proxy key to your server’s environment. Admins see it in Settings › Install. Keep it on the server, out of the page and out of your repository.
Load the script from your domain with this tag, in place of the one above:
<script defer src="/k3m9x2p7qa/script.js"
data-site="s_k3m9x2p7qa"
data-api="/k3m9x2p7qa/event"></script>s_k3m9x2p7qa stands for your site’s ID. Custom events and revenue have their own guide:Send custom events
Tag options
The tag works as it is. The script reads only its three data- attributes; defer is for the browser.
s_.Exclude your own visits
Run localStorage.setItem("_aoff", "1") in your browser’s console on your site. The script then sends nothing from that browser.
Replays and heatmaps use a second script, set up in Settings › Recording. It waits for the visitor’s consent by default. Consent for replays and heatmaps
Check that it works
Open Settings › Install for your site, then load any page of your site in another tab. Within a few seconds Install says the first page view was received. If the site’s Individual visits is on, it also shows that page view’s time, page, location, browser, device, source, and whether it came through your domain. With it off, the default, Install says only when the latest page view came.
If no page view shows up
If a minute passes without a page view, check these:
- The tag is on the deployed site, not only on your machine.
data-siteis exactly your site’s ID.- A content blocker in your own browser may stop the script. Try another browser, or set up Via your domain.
- A Content-Security-Policy must allow
app.lyli.ioinscript-srcandconnect-src. - Page views from an address your site doesn’t count, such as a staging domain or localhost, are turned away. Settings › General › Hostnames decides which addresses count (Choose which hostnames count).
What we keep
Cookieless by default: the script sets no cookies and stores nothing in the browser. Whether you need your visitors’ consent even so depends on the country; in Sweden and Germany, assume you do (consent, by place).
We never keep query strings, full referrer addresses, IP addresses, user-agent strings, or exact locations in our database; our hosting provider’s request logs keep IP addresses for about 7 days. Don’t send personal data in custom events.
What counts toward usage
Plans are sized by what a workspace records in a calendar month, across all its sites, links, and pixels.

