Send an event from JavaScript
The tracking script adds lundot.track (also window.lundot.track) once loaded.
// An event with a name
lundot.track("signup-button");
// An event with properties
lundot.track("signup-button", { plan: "pro", seats: 3 });
The script loads with defer, so guard calls that may run first:
window.lundot?.track?.("signup-button", { plan: "pro" });
To change a hit, pass a function that receives the defaults (website id, page address, title, referrer and so on) and returns the payload:
// A page view with your own address, for a virtual page
lundot.track((props) => ({ ...props, url: "/checkout/step-2" }));
// An event with properties, built from the defaults
lundot.track((props) => ({ ...props, name: "signup-button", data: { plan: "pro" } }));
lundot.track() with nothing, or a payload with no name, sends a page view.
From HTML attributes
Add data-lundot-event with the event name to any element; each data-lundot-event- attribute adds a property.
<button data-lundot-event="signup-button" data-lundot-event-plan="pro" data-lundot-event-seats="3">
Start free
</button>
- Sent on a click on the element or anything inside it.
- Values are always text. Use JavaScript for numbers, such as revenue.
- Browsers lower-case attribute names, so
data-lundot-event-userPlansendsuserplan. - On a link, the event is sent before the link is followed (new-tab and modifier clicks are not delayed).
- Under
data-auto-track="false", attribute clicks are not tracked.
Event names
| Rule | Detail |
|---|---|
| Length | At most 50 characters; longer names are cut |
| First character | Not =, +, -, @, a tab or a carriage return; refused with 400 to block spreadsheet formula injection |
| Case | Kept as sent: Signup and signup are two events |
Use short, stable names (signup, checkout-start) and put variable details in properties.
Properties
Properties are an object of keys and values; nested objects are allowed within limits.
| Limit | Value |
|---|---|
| Nesting | At most 3 levels, the top level included |
| Number of values | At most 50 of yours, nested values included. The top-level lundot key is the script's own: it does not count, but it holds at most 16 values, so do not use lundot as a key of your own |
| Size | At most 8 KiB (8,192 bytes) as JSON |
| Key length | At most 500 characters, counting the whole path (a.b.c) |
| Text values | Cut to 500 characters (the hit is kept) |
| Numbers | Stored with up to 4 decimal places |
| Arrays | Stored as text; over 500 characters, not stored |
| Request size | At most 64 KiB for one hit |
A hit over the nesting, number, size or key length limit is refused with 400 (such as Event data is nested deeper) and nothing is stored. Over 64 KiB gets 413.
Do not name a property lundot: the script overwrites it.
How privacy profiles change events
| Profile | Event names | Properties |
|---|---|---|
| Strict | Sent | Removed |
| Standard | Sent | Sent |
| Consented | Sent | Sent |
Strict also applies to browsers sending Do Not Track or Global Privacy Control. See Tracking script.
Revenue events
An event with revenue (a number above 0) and currency (such as "USD") is also recorded as revenue, shown in Product's Revenue view. Under Strict no revenue is recorded from events.
lundot.track("purchase", { revenue: 49.0, currency: "USD", plan: "pro" });
Revenue from Stripe is a separate connection, read with a restricted key.
Identify a visitor
lundot.identify("user-123", { plan: "pro" }) attaches an id (up to 50 characters) and properties to the visitor. It works only on the consented profile after your consent tool grants analytics consent (see Cookies and consent); Google Consent Mode is not enough. Otherwise, and under Do Not Track or Global Privacy Control, it does nothing. See Tracking script.
Events the script sends itself
The full script sends engagement, outbound_click and file_download by itself, except under Strict. See Tracking script.
Use events in reports
Product, Events lists them. Pick one to start a goal; funnels and journeys use the same events. See Concepts.