Documentation
Visly SDK
Zero-dependency, privacy-friendly analytics. Drop a single script tag into your website to start tracking pageviews, clicks, and custom events instantly. No npm install required.
Getting Started
Add the Visly script to the <head> of your website. That's it. It will automatically initialize and start tracking pageviews.
1<script
2 defer
3 src="https://oyoxrtpspyfxsndrdzvm.supabase.co/storage/v1/object/public/visly%20script/visly-v1.js"
4 data-project-id="YOUR_PROJECT_ID"
5></script>defer, so it won't block your page load or affect your Core Web Vitals.Configuration
Configure Visly by adding data- attributes directly to the script tag.
| Attribute | Type | Default | Description |
|---|---|---|---|
| data-project-id | string | — | Required. Your unique project identifier. |
| data-endpoint | string | (default) | Custom ingestion endpoint (if self-hosting). |
| data-debug | boolean | false | Enable verbose console logging for development. |
| data-capture-text | boolean | false | If true, captures the inner text of clicked elements. |
Auto-Tracking (No-Code)
Visly can automatically track clicks on specific elements without writing any JavaScript. Just add the data-va attribute to any HTML element.
Example
1<button data-va="signup_btn">
2 Get Started
3</button>
4
5<a href="/pricing" data-va="nav_pricing">Pricing</a>Manual Tracking
Once the script loads, it exposes a global window.visly object. Use this to track custom events or identify users.
Track Custom Events
1// Track a simple event
2window.visly.track("purchase_completed");
3
4// Track with custom properties
5window.visly.track("add_to_cart", {
6 item_id: "sku_123",
7 price: 49.99,
8 currency: "USD"
9});Identify Users
Link anonymous sessions to a specific user ID when they log in.
1// Call this after successful login
2window.visly.identify("user_555");Framework Guides
Next.js (App Router)
Add the script in your root layout. Using the native <script> tag inside <head> is often simplest for external scripts.
1export default function RootLayout({ children }) {
2 return (
3 <html lang="en">
4 <head>
5 <script
6 defer
7 src="https://oyoxrtpspyfxsndrdzvm.supabase.co/storage/v1/object/public/visly%20script/visly-v1.js"
8 data-project-id="YOUR_PROJECT_ID"
9 ></script>
10 </head>
11 <body>
12 {children}
13 </body>
14 </html>
15 )
16}React (SPA)
Simply add the script tag to your public/index.html file.
1<head>
2 <script
3 defer
4 src="https://oyoxrtpspyfxsndrdzvm.supabase.co/storage/v1/object/public/visly%20script/visly-v1.js"
5 data-project-id="YOUR_PROJECT_ID">
6 </script>
7</head>TypeScript Support
If you are using TypeScript, add this type definition to your global.d.ts or types.d.ts to avoid window errors.
1export {};
2
3declare global {
4 interface Window {
5 visly: {
6 track: (name: string, props?: Record<string, any>) => void;
7 identify: (id: string) => void;
8 };
9 }
10}API Reference
window.visly.track(name, props?)
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | The name of the event (e.g., 'click', 'signup'). |
props | object | No | A flat JSON object with additional metadata. |
window.visly.identify(userId)
| Parameter | Type | Required | Description |
|---|---|---|---|
userId | string | Yes | The unique ID of the user from your database. |