Tracking Script
Boxy automatically tracks pageviews. You can also track custom events, identify users, and associate companies.
Automatic Tracking
Once the script is installed, Boxy automatically tracks:
- Page views — URL, referrer, and page title
- Session duration — how long visitors stay
- Device & browser — desktop, mobile, tablet, browser name
- Geography — country based on IP (IP is never stored)
No cookies are used. Visitors are identified using a privacy-preserving hash that rotates daily.
Custom Events
Track any action on your site using the boxy.track() method:
// Track a simple event
boxy.track("signup");
// Track an event with properties
boxy.track("purchase", {
plan: "pro",
amount: 29,
currency: "USD",
});
// Track a button click
document.getElementById("cta-button").addEventListener("click", () => {
boxy.track("cta_click", { location: "hero" });
});
Note: Event names should be lowercase with underscores. Properties are optional and can be any JSON-serializable object.
User Identification
Link anonymous visitors to known users with boxy.identify(). This is useful for tracking user-level analytics after they sign in.
// Identify a user after login
boxy.identify("user_123", {
email: "jane@example.com",
name: "Jane Doe",
plan: "pro",
});
// Minimal identification (just the user ID)
boxy.identify("user_123");
The first argument is your internal user ID. The second argument is an optional object of user properties. Properties are merged — newer values override older ones.
Company Identification
Associate visitors with companies using boxy.company(). This is useful for B2B analytics.
// Associate the current visitor with a company
boxy.company("company_456", {
name: "Acme Inc",
industry: "SaaS",
plan: "enterprise",
employees: 150,
});
API Reference
| Method | Description |
|---|---|
boxy.track(event, properties?) | Track a custom event with optional properties |
boxy.identify(userId, properties?) | Identify the current visitor as a known user |
boxy.company(companyId, properties?) | Associate the current visitor with a company |